I have a dataset coming back that has 2 columns with Y or N values that indicate whether someone received a packet and whether or not they attended an event.
I need to have a checkbox in the datagrid that is checked if the value is "Y" and not checked if the value is "N"
The problem I'm having is I can't even get the checkboxes to show up in the datagrid, and since they aren't there, when I try to set the checkbox in the code behind, the chkBox object is nothing, so it throws an error.
Here's my datagrid:
The last 2 columns are hidden and contain the Y/N value. I can get that value in the ItemDataBound Sub, but I can't find the checkbox, so the chkBox.Checked = True/False step errors. If I skip setting the checkbox value, the grid loads, and I see the two checkbox columns, but the columns are empty.
Any idea what I'm doing wrong here? I'm sure it's something simple, I just can't seem to figure this on out.
Thanks
I need to have a checkbox in the datagrid that is checked if the value is "Y" and not checked if the value is "N"
The problem I'm having is I can't even get the checkboxes to show up in the datagrid, and since they aren't there, when I try to set the checkbox in the code behind, the chkBox object is nothing, so it throws an error.
Here's my datagrid:
<telerik:RadGrid ID="RadGrid1" OnSortCommand="RadGrid1_SortCommand" EnableViewState="true" MasterTableView-RetrieveAllDataFields="false" MasterTableView-CanRetrieveAllData="false" EnableEmbeddedSkins="false" runat="server" AllowPaging="true" AllowSorting="true" Width="930px" Height="150px" PageSize="25"> <ClientSettings ClientEvents-OnRowDblClick="dblClickRow" Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="false" Scrolling-AllowScroll="true" Scrolling-SaveScrollPosition="true" Scrolling-UseStaticHeaders="true"></ClientSettings> <SelectedItemStyle CssClass="grdSelectedRowStyleDefault" Font-Underline="false" /> <MasterTableView AutoGenerateColumns="False" RetrieveAllDataFields="false" EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="false"> <PagerStyle CssClass="Label" Mode="NumericPages" HorizontalAlign="right"></PagerStyle> <HeaderStyle CssClass="grdHeaderStyleDefault" BackColor="#CE0042" ForeColor="White" ></HeaderStyle> <ItemStyle CssClass="grdRowStyleDefault"></ItemStyle> <AlternatingItemStyle CssClass="grdRowAlternateStyleDefault"></AlternatingItemStyle> <NoRecordsTemplate><table width="100%"><tr><td align="center"><asp:label runat="server" ID="lblNoRec" Font-Bold="false" Font-Size="small" ForeColor="Black" CssClass="label" BackColor="Gainsboro">No Data To Display.</asp:label></td></tr></table></NoRecordsTemplate> <Columns> <telerik:GridBoundColumn DataField="REGISTRATIONID" Display="false" DataType="System.String"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="EVENTID" Display="false" DataType="System.String"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ACCOUNTID" HeaderStyle-Width="75px" HeaderText="<span title='Account ID'>Account ID</span>" DataType="System.String"> <ItemStyle Width="75px" Height="20px" BorderStyle="Solid" BorderWidth="1px" Wrap="false" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="LASTNAME" HeaderStyle-Width="150px" HeaderText="<span title='Last Name'>Last Name</span>" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Underline="false" DataType="System.String"> <ItemStyle Width="150px" Height="20px" BorderStyle="Solid" BorderWidth="1px" Wrap="false" HorizontalAlign="Center" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="FIRSTNAME" HeaderStyle-Width="135px" HeaderText="<span title='First Name'>Last Name</span>" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Underline="false" DataType="System.String"> <ItemStyle Width="135px" Height="20px" BorderStyle="Solid" BorderWidth="1px" Wrap="false" HorizontalAlign="Center" /> </telerik:GridBoundColumn> <telerik:GridNumericColumn DataField="PLEDGEAMOUNT" HeaderStyle-Width="70px" HeaderText="<span title='Pledge Amount'>Pledge</span>" HeaderStyle-HorizontalAlign="Right" DataType="System.Decimal" NumericType="Currency"> <ItemStyle Width="70px" Height="20px" HorizontalAlign="Right" BorderStyle="Solid" BorderWidth="1px" Wrap="false" /> </telerik:GridNumericColumn > <telerik:GridNumericColumn DataField="PAID" HeaderStyle-Width="70px" HeaderText="<span title='Paid'>Paid</span>" HeaderStyle-HorizontalAlign="Right" DataType="System.Decimal" NumericType="Currency"> <ItemStyle Width="70px" Height="20px" HorizontalAlign="Right" BorderStyle="Solid" BorderWidth="1px" Wrap="false" /> </telerik:GridNumericColumn > <telerik:GridBoundColumn DataField="TEAMCODE" HeaderStyle-Width="100px" HeaderText="<span title='Team Code'>Team Code</span>" DataType="System.String"> <ItemStyle Width="100px" Height="20px" BorderStyle="Solid" BorderWidth="1px" Wrap="false" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="REGISTRATIONDATE" HeaderStyle-Width="75px" HeaderText="<span title='Registration Date'>Reg Date</span>" DataType="System.String"> <ItemStyle Width="75px" Height="20px" BorderStyle="Solid" BorderWidth="1px" Wrap="false" /> </telerik:GridBoundColumn> <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn1" HeaderStyle-Width="25px" HeaderStyle-HorizontalAlign="Center" HeaderText="<span title='Packet Sent'>P</span>"> <EditItemTemplate> <asp:CheckBox ID="chkPACRECIND" AutoPostBack="false" runat="server" /> </EditItemTemplate> <ItemStyle Width="25px" BorderStyle="Solid" BorderWidth="1px" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn2" HeaderStyle-Width="25px" HeaderStyle-HorizontalAlign="Center" HeaderText="<span title='Attended'>A</span>"> <EditItemTemplate> <asp:CheckBox Runat="server" ID="chkATTIND" /> </EditItemTemplate> <ItemStyle Width="25px" BorderStyle="Solid" BorderWidth="1px" /> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="PACKETSENTDATE" HeaderStyle-Width="75px" HeaderText="<span title='Packet Sent Date'>Packet Sent Date</span>" DataType="System.String"> <ItemStyle Width="75px" Height="20" BorderStyle="Solid" BorderWidth="1px" Wrap="false" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="BIBTEXT" HeaderStyle-Width="75px" HeaderText="<span title='Bib Number'>Bib Number</span>" DataType="System.String"> <ItemStyle Width="75px" Height="20" BorderStyle="Solid" BorderWidth="1px" Wrap="false" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ATTENDEDIND" Display="false" DataType="System.String"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="PACKETRECEIVEDIND" Display="false" DataType="System.String"> </telerik:GridBoundColumn> </Columns> </MasterTableView></telerik:RadGrid>The last 2 columns are hidden and contain the Y/N value. I can get that value in the ItemDataBound Sub, but I can't find the checkbox, so the chkBox.Checked = True/False step errors. If I skip setting the checkbox value, the grid loads, and I see the two checkbox columns, but the columns are empty.
lstr_PacketReceived = item("PACKETRECEIVEDIND").Text
Dim chkBox As CheckBox = DirectCast(e.Item.FindControl("CheckBox1"), CheckBox)If Not (lstr_PacketReceived Is Nothing) Then If lstr_PacketReceived.Equals("Y") Then chkBox.Checked = True Else chkBox.Checked = False End IfEnd IfAny idea what I'm doing wrong here? I'm sure it's something simple, I just can't seem to figure this on out.
Thanks