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

Getting DropDownList Value with RadGrid User Control Edit Form

1 Answer 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peng Hooi
Top achievements
Rank 1
Peng Hooi asked on 29 Feb 2012, 01:47 PM
Hi,
 
I want to get the dropdownlist.selectedvalue that located outside from the radgrid and pass the value to the User Custom Edit From in Insert/Edit mode. how can it possible?

.aspx
<asp:DropDownList ID="DropDownList1" runat="server">
       <asp:ListItem Value="Item1">Item1</asp:ListItem>
       <asp:ListItem>Item2</asp:ListItem>
       <asp:ListItem>Item3</asp:ListItem>
   </asp:DropDownList>
 
   <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" DataSourceID="SDSDropDownList"
       GridLines="None" Skin="WebBlue">
       <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="UID"
           DataSourceID="SDSDropDownList" EditMode="PopUp">
            <Columns>
               <telerik:GridEditCommandColumn ButtonType="ImageButton">
               </telerik:GridEditCommandColumn>
               <telerik:GridBoundColumn DataField="UID" DataType="System.Int32" FilterControlAltText="Filter UID column"
                   HeaderText="UID" ReadOnly="True" SortExpression="UID" UniqueName="UID" Visible="False">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="DataValue" FilterControlAltText="Filter DataValue column"
                   HeaderText="DataValue" SortExpression="DataValue" UniqueName="DataValue">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="DataText" FilterControlAltText="Filter DataText column"
                   HeaderText="DataText" SortExpression="DataText" UniqueName="DataText">
               </telerik:GridBoundColumn>
               <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmText="Are You Sure You Want to Delete ?"
                   Text="Delete" UniqueName="Delete">
               </telerik:GridButtonColumn>
           </Columns>
           <EditFormSettings UserControlName="DropDownListGridDetail.ascx" EditFormType="WebUserControl">
               <PopUpSettings Width="500px"></PopUpSettings>
           </EditFormSettings>
       </MasterTableView>
   </telerik:RadGrid>

i want DropDownList1.selectedvalue to be parse to label1 at DropDownListGridDetail.ascx 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Mar 2012, 05:32 AM
Hello,

Try the following code.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
 {
  GridEditFormItem editFormItem = e.Item as GridEditFormItem;
  UserControl MyUserControl = editFormItem.FindControl(GridEditFormItem.EditFormUserControlID) as UserControl;
  DropDownList ddl = MyUserControl.FindControl("DropDownList1") as DropDownList;          
 }
}

-Shinu.
Tags
Grid
Asked by
Peng Hooi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or