|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to use check box in data gridI want to use check box in data grid for boolean value, let said about an invoice record paid status. I've used TemplateColumn for this purpose. <asp:datagrid id="dgrInvoices" runat=server> <asp:TemplateColumn><asp:checkbox id="chkPaid" runat="server"></asp:checkbox></asp:TemplateColumn> <asp:BoundColumn>..........<<several bound column>> </asp:datagrid> has i done it right ? now, if an invoice record paid status is true i want the checkbox to be checked. i've try this in the datagrid event ItemCreated (is this the right event or the ItemDataBound ?), if put //real C# code //make a reference CheckBox chkToUpdate = (CheckBox)e.Item.Cells[0].FindControl("chkPaid"); //pseudocode if ..... <<check the paid status>> then ....... i keep getting "Specified cast is invalid" error. please help, Hendri Irawan Hi Hendri,
The checkbox should be inside ItemTemplate tags. It's like <asp:TemplateColumn HeaderText="Header"> <ItemTemplate> <asp:checkbox id="chkPaid" runat="server"></asp:checkbox> </ItemTemplate> </TemplateColumn> HTH Elton Wang elton_w***@hotmail.com >-----Original Message----- let said about an >hi all, please help me > >I want to use check box in data grid for boolean value, >invoice record paid status. I've used TemplateColumn for checkbox to be this purpose. > ><asp:datagrid id="dgrInvoices" runat=server> > <asp:TemplateColumn><asp:checkbox id="chkPaid" >runat="server"></asp:checkbox></asp:TemplateColumn> > <asp:BoundColumn>..........<<several bound column>> ></asp:datagrid> > >has i done it right ? > >now, if an invoice record paid status is true i want the >checked. i've try this event or the > >in the datagrid event ItemCreated (is this the right >ItemDataBound ?), if put [0].FindControl("chkPaid");>//real C# code >//make a reference >CheckBox chkToUpdate = (CheckBox)e.Item.Cells Show quoteHide quote > >//pseudocode >if ..... <<check the paid status>> >then ....... > >i keep getting "Specified cast is invalid" error. > >please help, > >Hendri Irawan > > > > >. >
Bees knees of grid controls for ASP.NET
Datagrid Not Displaying newbie to datagrids Changea buttoncommand for one record only Problem with Paging and Parameter passing using Hyperlink Column @ DATAGRID OnItemDataBound Problem playing around a DataGrid DataGrid with manual dataSource Quick! Simple method for editing a nested datagrid! DataGridPageChangedEventHandler not firing |
|||||||||||||||||||||||