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

Radgrid item controls

3 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mustafa
Top achievements
Rank 1
mustafa asked on 01 Apr 2011, 10:19 AM
 



for (int intAy = 1; intAy < 13; intAy++)
           {
               Label17.Text = GridView1.Items[i].Controls[intAy].Controls.Count.ToString();                
               string strTemp = GridView1.Items[i].Controls[intAy].Controls[1].ID;   
            
             
           }

at this code , Label17.Text return 0 so , i couldnt get strTemp !

3 Answers, 1 is accepted

Sort by
0
mustafa
Top achievements
Rank 1
answered on 01 Apr 2011, 12:28 PM
please help me , i have no enough time :(
0
mustafa
Top achievements
Rank 1
answered on 01 Apr 2011, 10:27 PM
:(
0
Princy
Top achievements
Rank 2
answered on 04 Apr 2011, 04:31 AM
Hello Mustafa,

In order to loops through each RadGrid row and to get the cell value, try the following code snippet.

ASPX:
<Columns>
    <telerik:GridBoundColumn DataField="FirstName" UniqueName="FirstName">
    </telerik:GridBoundColumn>
    <telerik:GridTemplateColumn>
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%#Eval("FirstName") %>'></asp:Label>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
</Columns>


C#:
foreach (GridDataItem item in RadGrid1.Items)//loops through each grid item
      {
          string boundcol_value = item["FirstName"].Text;//accessing boundcolumn Value
          Label lb=(Label)item.FindControl("Label1");//accessing control inside ItemTemplate of GridTemplateColumn
          string value = lb.Text;
      }

And refer the following documentation for more information on this.
Accessing cells and rows

 Please elaborate your requirement if it doesn't help.

Thanks,
Princy.
Tags
Grid
Asked by
mustafa
Top achievements
Rank 1
Answers by
mustafa
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or