♠ Posted by uvesh in Gridview in asp.net at Saturday, August 23, 2014
What is gridview conntrol in asp.net and its use ?
- gridview is a very useful control in asp.net.
- gridview is mainly uses for display data in tabularform.
- it also can edit, update, insert data.
- this can help you to display and format tabular data very easy and fastest way.
- we can format the gridview's nearly all parts as example header, row, alternate row, paging etc.
- even we can place insert,edit,delete button for each row.
Example of Grid view control using .aspx page in asp.net as follow:
In this simple example we create a default formatted gridview. we also create a sqldatasource control populate the data source by a simple database query.
<script runat="server">
</script>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ClientId"
DataSourceID="SqlDataSource_demo">
<Columns>
<asp:BoundField DataField="ClientId" HeaderText="ClientId" ReadOnly="True"
SortExpression="ClientId" />
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName"
SortExpression="CompanyName" />
<asp:BoundField DataField="ContactName" HeaderText="ContactName"
SortExpression="ContactName" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="PinCode" HeaderText="PinCode"
SortExpression="PinCode" />
<asp:BoundField DataField="State" HeaderText="State"
SortExpression="State" />
<asp:BoundField DataField="Country" HeaderText="Country"
SortExpression="Country" />
<asp:BoundField DataField="Moble" HeaderText="Moble" SortExpression="Moble" />
<asp:BoundField DataField="Landline" HeaderText="Landline" SortExpression="Landline" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource_demo" runat="server"
ConnectionString="<%$ ConnectionStrings:AppConnectionString1 %>"
SelectCommand="SELECT * FROM [Client]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
Improve Your Answer as comment below.
If our post is useful please share and comment on our post for more post and detail Visit :
http://aspdotnethelpmaster.blogspot.in/
0 comments:
Post a Comment