Home > DeveloperSection > Forums > How to use FormView in asp.net.
Ankit Singh

Total Post:341

Posted on    November-01-2015 11:10 PM

 .NET C#  ASP.Net 

 1 Reply(s)
 277  View(s)
Rate this:
i want to use formView in asp.net please help me .

aditya kumar Patel

Total Post:250

Posted on    November-01-2015 11:26 PM

The FormView control is used to display a single record from a data source in a table.
It is Server Side Control in asp.net.

<asp:FormView ID="FormView1" runat="server" GridLines="Horizontal">


<div style="background-color: #BBB138;font-size: 15px;font-weight: bold;padding: 10px;">Employee Details</div>



<div style="background-color:#efb558; padding:20px;">

<div style="padding-left: 10px;">

ID: <%#Eval("Emp_ID") %>


<div style="padding-left: 10px;">

Name: <%#Eval("Emp_Name") %>


<div style="padding-left: 10px;">

Salary: <%#Eval("Emp_Sal") %>





string constr = ConfigurationManager.ConnectionStrings["forumConnectionString"].ToString(); // connection string

SqlConnection con = new SqlConnection(constr);





SqlCommand com = new SqlCommand("select *from Employee", con); // table name

SqlDataAdapter da = new SqlDataAdapter(com);

DataSet ds = new DataSet();

da.Fill(ds); // fill dataset

FormView1.DataSource = ds.Tables[0]; //set DataSource FormView

FormView1.DataBind(); //binding FormView






Don't want to miss updates? Please click the below button!

Follow MindStick