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

Find Controls from RadGrid

3 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dibyendu
Top achievements
Rank 1
Dibyendu asked on 03 Dec 2008, 01:16 PM

Hi,
I am using RadGrid and use the MasterTableViewEditForm Template where i used DropDownList Box. But I want to fill the Dropdown in runtime. So I want to get the specific Dropdownlist Control. I write the following code but it's not working

Dim 

 

cb As DropDownList

 

 

cb =

CType(Me.RadGrid1.MasterTableView.FindControl("DropdownList1"), DropDownList)

 

 

 

 

 

Thanks
Dibyendu
 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Dec 2008, 04:48 AM
Hi Dibyendu,

You can try the following code snippet to access a control in the FormTemplate when the Grid is in edit mode.


ASPX:
 <EditFormSettings EditFormType="Template"
                      <FormTemplate> 
                          <asp:DropDownList ID="DropDownList1" runat="server"
                          </asp:DropDownList> 
                      </FormTemplate> 
                    </EditFormSettings> 

VB:
 
 
     Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) 
         If (TypeOf e.Item Is GridEditFormItem) AndAlso (e.Item.IsInEditMode) Then 
             Dim editItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem) 
             Dim ddl As DropDownList = DirectCast(editItem.FindControl("DropDownList1"), DropDownList) 
             
         End If 
     End Sub 
 
 

Hope this helps..
Shinu.
0
Dibyendu
Top achievements
Rank 1
answered on 04 Dec 2008, 01:23 PM
Dear Shinu,
Thanks for reply. I follow your code but it gives -- 

Unable to cast object of type 'Telerik.WebControls.GridCommandItem' to type 'Telerik.WebControls.GridEditFormItem'.

0
Dibyendu
Top achievements
Rank 1
answered on 04 Dec 2008, 01:43 PM
Dear Shinu,
Thanks for reply. I follow your code but it gives -- 

Unable to cast object of type 'Telerik.WebControls.GridCommandItem' to type 'Telerik.WebControls.GridEditFormItem'.

 

Tags
Grid
Asked by
Dibyendu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dibyendu
Top achievements
Rank 1
Share this question
or