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

[Solved] Accessing radgrid GridBoundColumn inside the dropdownlist selected inndex change

1 Answer 160 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amarinder Singh
Top achievements
Rank 1
Amarinder Singh asked on 29 Jan 2010, 01:37 PM
Hello,

         
<telerik:GridTemplateColumn UniqueName="StatusColumn" HeaderText="Approved Status">  
                <ItemTemplate> 
                   <asp:Label id="lblStatus" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "status") %>'>  
                       
                   </asp:Label> 
                </ItemTemplate> 
                <EditItemTemplate> 
                   <asp:DropDownList id="ddlApprovalStatus" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlApprovalStatus_SelectedIndexChanged" > 
                    <asp:ListItem Text="Pending" Value="False" Selected="True"></asp:ListItem> 
                   <asp:ListItem Text="Approved" Value="True"></asp:ListItem> 
                   </asp:DropDownList> 
                                   </EditItemTemplate> 
                <ItemStyle Width="40px" /> 
            </telerik:GridTemplateColumn> 
i have dropdown list as shown above. On its selected index change event i want to acess  GridBoundColumn  row, to get some information. How can it be done.
GridBoundColumn is 
<telerik:GridBoundColumn DataField="id" DataType="System.Int32" HeaderText="id"   
                ReadOnly="True" SortExpression="id" UniqueName="id" Visible="false">  
                <ItemStyle Width="100px" />  
            </telerik:GridBoundColumn> 
 i want to get this "id" in selectedindexchange event 

my selectedchange event is
protected void ddlApprovalStatus_SelectedIndexChanged(object source, System.EventArgs e)  
        {  
              
 
        } 

Thanks
Amarinder

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Feb 2010, 06:09 AM
Hello Amarinder Singh,

Set the DataKeyNames as "id" and then you can use the following code snippet for getting the corresponding id in the DropDownList SelectedIndexChanged event.

C#:
 
    protected void ddlApprovalStatus_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        DropDownList dropDownList = (DropDownList)sender; 
        GridDataItem item = (GridDataItem)dropDownList.NamingContainer; 
        String str = item.GetDataKeyValue("id").ToString(); 
        Response.Write(str); 
    } 

ASPX:
 
<MasterTableView EditMode="InPlace" PageSize="10" DataSourceID="SqlDataSource1" DataKeyNames="id"

Hope this helpful for you,
Shinu.
Tags
Grid
Asked by
Amarinder Singh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or