Tutorial by Examples

There are two ways you can bind a GridView. You can either manually do it by setting the DataSource property and calling DataBind(), or you can use a DataSourceControl such as a SqlDataSource. Manual Binding Create your GridView: <asp:GridView ID="gvColors" runat="server"&g...
There are seven different column types that can be used within a GridView. <asp:GridView ID="GridView1" runat="server"> <Columns> ... </Columns> </asp:GridView> BoundField: <asp:BoundField DataField="EmployeeID" Heade...
Starting with Asp.net 4.5 web controls can take advantage from strongly-typed binding to get IntelliSense support and compiletime errors. Create a class, which holds your model: public class Album { public int Id { get; set; } public string Name { get; set; } public string Artist {...
GridViews allow commands to be sent from a GridView row. This is useful for passing row-specific information into an event handler as command arguments. To subscribe to a command event: <asp:GridView ID="GridView1" ... OnRowCommand="GridView1_RowCommand"> Buttons are t...
ObjectDataSource If using an ObjectDataSource, almost everything is handled for you already, just simply tell the GridView to AllowPaging and give it a PageSize. <asp:GridView ID="gvColors" runat="server" DataSourceID="sdsColors" AllowPaging="Tr...
Gridviews are more useful if we can update the view as per our need. Consider a view with a lock/unlock feature in each row. It can be done like: Add an update panel: <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> </asp:UpdatePane...

Page 1 of 1