about
services
portfolio
contact
news
client login
dev
sitemap
ASP.NET datagrid and checkbox tutorial
Here is a brief tutorial on how to use checkboxes within a datagrid. First lets start with the HTML portion of the tutorial (the .aspx page, actually).
<asp:DataGrid id="dgPerson" runat="server" Width="280px" AutoGenerateColumns="False"> <Columns> <asp:TemplateColumn Visible="False" HeaderText="User ID"> <ItemTemplate> <asp:Label id="lblUser" Text='<%# DataBinder.Eval(Container.DataItem, "person_id") %>' runat="server" /> </ItemTemplate> </asp:TemplateColumn> <asp:BoundColumn DataField="last_name" HeaderText="Last Name"> <HeaderStyle Width="300px"></HeaderStyle> </asp:BoundColumn> <asp:BoundColumn DataField="first_name" HeaderText="First Name"> <HeaderStyle Width="300px"></HeaderStyle> </asp:BoundColumn> <asp:TemplateColumn HeaderText="Add"> <HeaderStyle Width="12px"></HeaderStyle> <ItemStyle HorizontalAlign="Center"></ItemStyle> <ItemTemplate> <asp:CheckBox id="chkRemove" runat="server" /> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid>
back
next