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

Total Post:341

Points:2389
Posted on    November-01-2015 11:10 PM

 .NET C#  ASP.Net 
Ratings:


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


aditya kumar Patel

Total Post:250

Points:1782
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">

<HeaderTemplate>

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

</HeaderTemplate>

<ItemTemplate>

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

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

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

</div>

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

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

</div>

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

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

</div>

</div>

</ItemTemplate>

</asp:FormView>

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

SqlConnection con = new SqlConnection(constr);

 

 

con.Open();

 

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