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

Disable Dropdown

4 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Monisha Bhatia
Top achievements
Rank 1
Monisha Bhatia asked on 22 Oct 2008, 10:07 PM
Hi,

I am using Radgrid and i want to enable and disable the Dropdownlist on the button click in my Edit Form. Both Button and the Dropdown are in the EditForm of my RadGrid. Please let me know if this is possible.


Regards
Monisha.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Oct 2008, 04:00 AM
Hello Monisha,

Try out the following code to disable a DropDown in the EditFormTemplate by clicking on a button.
aspx:
 <EditFormSettings EditFormType="Template" > 
                <FormTemplate>        
                     
                    <asp:Button ID="Button3" runat="server" Text="Button" OnClick="Button3_Click" /> 
                    <asp:DropDownList ID="DropDownList1" runat="server"
                    </asp:DropDownList> 
                     
                </FormTemplate>                 
                </EditFormSettings> 

cs:
protected void Button3_Click(object sender, EventArgs e) 
    { 
        Button btn = (Button)sender; 
        GridEditFormItem formItem = (GridEditFormItem)btn.NamingContainer; 
        DropDownList ddl = (DropDownList)formItem.FindControl("DropDownList1"); 
    } 

Thanks
Princy.
0
Monisha Bhatia
Top achievements
Rank 1
answered on 23 Oct 2008, 04:40 PM

Hi,

I used the same code, but I am able to set the dropdown as visible = false.
When I try disable it, the dropdown is not getting Disabled can you tell me the reason. Below is the code which I am using

 

Protected

Sub btnNewPrjName_Click(ByVal sender As Object, ByVal e As System.EventArgs)

 

 

If sender IsNot Nothing Then

 

 

Dim btnNewPrjName As Button = sender
Dim ddlPrjShrtName As DropDownList = CType(EditForm.FindControl("ddlPrjShrtName"), DropDownList)

 

ddlPrjShrtName.Enable =

False

 

 

 

End If
End Sub

 

0
Shinu
Top achievements
Rank 2
answered on 24 Oct 2008, 05:13 AM
Hi,

I tried the following code snippet to disable the DropDownList and it is working well on my end. Give a try with the following code snippet and see if it is working

VB:
 
     Protected Sub Button3_Click(sender As Object, e As EventArgs) 
         Dim btn As Button = DirectCast(sender, Button) 
         Dim formItem As GridEditFormItem = DirectCast(btn.NamingContainer, GridEditFormItem) 
         Dim ddl As DropDownList = DirectCast(formItem.FindControl("ddlPrjShrtName"), DropDownList) 
         ddl.Enabled = False 
         
     End Sub 
 


Regards
Shinu
0
Monisha Bhatia
Top achievements
Rank 1
answered on 24 Oct 2008, 08:20 PM
Hi,

I tried the same code but it is still not working. Please help me with this.

Regards
Monisha
Tags
Grid
Asked by
Monisha Bhatia
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Monisha Bhatia
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or