checkbox in Datagrid? help

  • Thread starter Thread starter '[] WiRaN
  • Start date Start date
You have to make templated columns for your datagrid. The following
example would make a datagrid with only 1 column. This column would
have a simple checkbox, and the checked property of the checkbox is
set with a field named "BoolField" in the data source.

Hope this helps!


<asp:datagrid id="DataGrid1" runat="server" ... >
<Columns>
<asp:TemplateColumn HeaderText="Column 1">
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server"
Checked='<%#DataBinder.Eval(Container.DataItem,
"BoolField").ToString() == "True"?true:false%>'></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

Matt
 
Back
Top