How to find control inside GridTableView

2 posts, 0 answers
  1. Mayank
    Mayank avatar
    5 posts
    Member since:
    Jan 2014

    Posted 11 Apr 2014 Link to this post


     protected void GridsettSave_Click(object sender, EventArgs e)
            {
     foreach (GridDataItem item in RadGridCommonSetting.Items)
                {
                    RadSkinManager Skin = item.FindControl("Skin") as RadSkinManager;
                    DropDownList CellSelectionMode = item.FindControl("CellSelectionMode") as DropDownList;
              }
           }
    but this code shows Null every time
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Apr 2014 in reply to Mayank Link to this post

    Hi Mayank,

    I am not sure about your requirement. I guess that you are trying to access ItemTemplate controls of RadGrid on Button Click event. Please have a look into the sample code snippet which works fine at my end. 

    ASPX:
    <telerik:RadGrid ID="RadGridCommonSetting" runat="server" DataSourceID="SqlDataSource1"
        AutoGenerateColumns="false">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID" UniqueName="OrderID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CustomerID" UniqueName="CustomerID">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn UniqueName="Template">
                    <ItemTemplate>
                        <telerik:RadSkinManager ID="Skin" runat="server">
                        </telerik:RadSkinManager>
                        <asp:DropDownList ID="CellSelectionMode" runat="server">
                            <asp:ListItem Text="Item1">
                            </asp:ListItem>
                        </asp:DropDownList>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <telerik:RadButton ID="RadButton1" runat="server" Text="AccessItem" OnClick="RadButton1_Click">
    </telerik:RadButton>

    C#:
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        foreach (GridDataItem item in RadGridCommonSetting.Items)
        {
            RadSkinManager skin = item.FindControl("Skin") as RadSkinManager;
            DropDownList CellSelectionMode = item.FindControl("CellSelectionMode") as DropDownList;
        }
    }

    Please elaborate your requirement if it doesn't help. 
    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top