How to use FormView in asp.net.

Total Post:341

Points:2389
C#  ASP.Net 
 833  View(s)
Ratings:
Rate this:
i want to use formView in asp.net please help me .
  1. Post:279

    Points:1987
    Re: How to use FormView in asp.net.

    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 

     

     

     

     

      Modified On Apr-10-2018 05:08:06 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!