HOW TO USE FORMVIEW IN ASP.NET.

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
C#  ASP.Net 
 546  View(s)
Ratings:
Rate this:
i want to use formView in asp.net please help me .
  1. aditya kumar Patel

    Post:254

    Points:1810
    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

     

     

     

     

     

Answer

NEWSLETTER

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