Hi,
Please excuse my confusion on this! What I am attempting to do is to place a checkbox column in a grid, allow the user to select one or more checkboxes, then have a button on the page that kicks off an Ajax call to the code behind. The code behind would loop through the grid and if the checkbox for that row is checked read a column that contains the unique key value and do something with it. I have tried with the various column types to no avail, maybe I have a setting wrong...not sure. Anyway can someone provide some assistance?
Here is what my simple test column looks like...the second column is the ID column
<telerik:RadGrid ID="RadGridAdHoc" runat="server" Width="100%" Height="160px" CssClass="center" AllowPaging="true" AllowSorting="true" AllowCustomPaging="False" PageSize="30" EnableAJAX="False" EnableAJAXLoadingTemplate="true" EnableEmbeddedSkins='true' Skin="Office2007" EnableViewState='false'>
<PagerStyle AlwaysVisible='true' Mode='NextPrevAndNumeric' />
<ClientSettings>
<ClientEvents />
<Selecting AllowRowSelect="true" EnableDragToSelectRows="false" UseClientSelectColumnOnly='true' />
<Scrolling UseStaticHeaders="True" AllowScroll="true" SaveScrollPosition="false" />
<Resizing AllowColumnResize="False" />
</ClientSettings>
<MasterTableView AllowAutomaticUpdates="true" AutoGenerateColumns="false" AllowMultiColumnSorting="False" TableLayout="fixed" >
<Columns>
<telerik:GridTemplateColumn HeaderText="Select" UniqueName="ConfirmOrder" DataField='DataIDValue'>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="DataIDValue" UniqueName="DataIDValue" Display='false'>
</telerik:GridBoundColumn>
</telerik:RadGrid>
Here is what is in my code behind looks like..The ajax call on the button click works fine and it gets the the sub holding the code below however it does not ever enter the loop....the RadGridAdHoc.MasterTableView.Items count = 0 so skips over it.
For Each item As GridDataItem In RadGridAdHoc.MasterTableView.Items
For Each col As GridColumn In RadGridAdHoc.MasterTableView.RenderColumns
If col.UniqueName = "Confirm" Then
Dim chkbx As CheckBox = DirectCast(item("ConfirmOrder").Controls(0), CheckBox)
If chkbx.Checked = True Then
'Get ID value from row with checked checkbox
'How do I get the value if the DataID column here?
End If
End If
Next
Next
I guess also not really sure what column type is best to use...I have tried the GridCheckBoxColumn and the GridClientSelectColumn without success....and now GridTemplateColumn.....the maybe one type is better to use?
How can I retrieve the value of the DataID column once the checkbox is identified as checked?
Any assistance anyone could provide would be greatly appreciated! Thanks in advance,
Kelvin
Please excuse my confusion on this! What I am attempting to do is to place a checkbox column in a grid, allow the user to select one or more checkboxes, then have a button on the page that kicks off an Ajax call to the code behind. The code behind would loop through the grid and if the checkbox for that row is checked read a column that contains the unique key value and do something with it. I have tried with the various column types to no avail, maybe I have a setting wrong...not sure. Anyway can someone provide some assistance?
Here is what my simple test column looks like...the second column is the ID column
<telerik:RadGrid ID="RadGridAdHoc" runat="server" Width="100%" Height="160px" CssClass="center" AllowPaging="true" AllowSorting="true" AllowCustomPaging="False" PageSize="30" EnableAJAX="False" EnableAJAXLoadingTemplate="true" EnableEmbeddedSkins='true' Skin="Office2007" EnableViewState='false'>
<PagerStyle AlwaysVisible='true' Mode='NextPrevAndNumeric' />
<ClientSettings>
<ClientEvents />
<Selecting AllowRowSelect="true" EnableDragToSelectRows="false" UseClientSelectColumnOnly='true' />
<Scrolling UseStaticHeaders="True" AllowScroll="true" SaveScrollPosition="false" />
<Resizing AllowColumnResize="False" />
</ClientSettings>
<MasterTableView AllowAutomaticUpdates="true" AutoGenerateColumns="false" AllowMultiColumnSorting="False" TableLayout="fixed" >
<Columns>
<telerik:GridTemplateColumn HeaderText="Select" UniqueName="ConfirmOrder" DataField='DataIDValue'>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="DataIDValue" UniqueName="DataIDValue" Display='false'>
</telerik:GridBoundColumn>
</Columns>
</MasterTableView></telerik:RadGrid>
Here is what is in my code behind looks like..The ajax call on the button click works fine and it gets the the sub holding the code below however it does not ever enter the loop....the RadGridAdHoc.MasterTableView.Items count = 0 so skips over it.
For Each item As GridDataItem In RadGridAdHoc.MasterTableView.Items
For Each col As GridColumn In RadGridAdHoc.MasterTableView.RenderColumns
If col.UniqueName = "Confirm" Then
Dim chkbx As CheckBox = DirectCast(item("ConfirmOrder").Controls(0), CheckBox)
If chkbx.Checked = True Then
'Get ID value from row with checked checkbox
'How do I get the value if the DataID column here?
End If
End If
Next
Next
I guess also not really sure what column type is best to use...I have tried the GridCheckBoxColumn and the GridClientSelectColumn without success....and now GridTemplateColumn.....the maybe one type is better to use?
How can I retrieve the value of the DataID column once the checkbox is identified as checked?
Any assistance anyone could provide would be greatly appreciated! Thanks in advance,
Kelvin