This is a migrated thread and some comments may be shown as answers.

[Solved] Iterate Grid Rows

1 Answer 280 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 08 Jan 2008, 10:05 PM
Simple task - I have a grid that exposes checkboxes and on a button click (postback to the server) I would like to run a foreach loop to find out which rows were selected and then grab column values within those rows.  I get the idea of the UniqueName but I'm just struggling a little bit on the exact syntax of the iteration.

Here is my Grid:

 <telerik:RadGrid ID="rdgrdDistricts" AllowMultiRowSelection="true" runat="server" BorderWidth="0px" 

                                 DataSourceID="Districts" GridLines="None" Skin="Web20" Width="400px">

                   <MasterTableView AutoGenerateColumns="false" DataSourceID="Districts">

                        <AlternatingItemStyle BackColor="WhiteSmoke" />

                        <Columns>

                            <telerik:GridClientSelectColumn UniqueName="Export" HeaderText="Export" />

                            <telerik:GridBoundColumn UniqueName="DistrictId" DataField="DistrictId" Visible="False" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" ForceExtractValue="None" />

                            <telerik:GridBoundColumn UniqueName="DistrictName" DataField="DistrictName" HeaderText="District" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" ForceExtractValue="None" />

                        </Columns>

                    </MasterTableView>

                    <ClientSettings>

                        <Selecting AllowRowSelect="True" />

                        <Scrolling AllowScroll="True" UseStaticHeaders="false"  />

                    </ClientSettings>

                </telerik:RadGrid>


Thanks!

1 Answer, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 2
answered on 09 Jan 2008, 12:14 AM
Ok, turns out that it was a conflict with a namespace.  I had Telerik.WebControls imported and I changed it to Telerik.Web.UI and the following allows me to iterate through my Grid rows:

For Each item As GridDataItem In rdgrdDistricts.MasterTableView.Items

lblMessage.Text = item("DistrictName").Text

Next

Tags
Grid
Asked by
Michael
Top achievements
Rank 2
Answers by
Michael
Top achievements
Rank 2
Share this question
or