Handling events in a datagrid

D

Deepak

Hi,
I am having a datagrid with 3 radiobuttons in one template column and a
textbox in another template column. How can I disable or enable the textbox
in the second template column depending on the value of the radio buttons?
I am also giving my datagrid for ur reference.

<asp:DataGrid id="MyDataGrid" runat="server" OnSortCommand="MyDataGrid_Sort"
AllowPaging="True"
PageSize="10"
BorderColor="black"
BorderWidth="1"
GridLines="Both"
autodraw = "False"
AllowSorting="true"
AutoGenerateColumns="false"
Width=100%

<columns>

<asp:templatecolumn headertext = "<font style='text-decoration:none'
color='#ffffff' Title='Click here to SORT' Title='Click here to SORT'>
Approve/Reject</font>" >
<ItemTemplate >
<font = "LHBoxFont">
<asp:radiobutton id= "rbtnApprove" GroupName ="a" runat="server" /> Pay
Claims

<br>
<asp:radiobutton id= "rbtnReject" GroupName ="a" runat="server" /> Reject
Claims
<br>
<asp:radiobutton id= "rbtnIgnore" checked="true" GroupName ="a"
runat="server" /> Ignore Claims

</font>
<itemStyle width = 15% Cssclass = lblHeader align=center>
</itemStyle>
</ItemTemplate>


</asp:templatecolumn>


<asp:templatecolumn headertext = "<font style='text-decoration:none'
color='#ffffff' Title='Click here to SORT' Title='Click here to SORT'> Paid
Date/Comments</font>" >
<ItemTemplate>
<asp:textbox id= "txtPayClaims" runat="server"/>
</ItemTemplate>
<itemStyle width = 25% Cssclass = lblHeader >
</itemStyle>
</asp:templatecolumn>

</columns>

</asp:DataGrid>


In the above scenario, I want to enable the textbox,"txtPayClaims", if the
value in the radiobutton, "rbtnApprove" is selected and must disable the
textbox if the value in the radiobutton, "rbtnReject" is selected .

Is there any way I can do this??

Thanks,
Deepak
 
S

Saravana

You can attach OnCheckedChanged eventhandler to radio button and set its
autopostback property to true. Then in that eventhandler you can access the
textbox, so you disable or enable it depending upon the requirement. In the
event handler you can write code like this to access the text box

Dim oTextbox As TextBox

Dim oRadio As RadioButton

oRadio = CType(sender, RadioButton)

oTextbox = oTextbox.Parent.FindControl("txtPayClaims")

oTextbox.enabled = "Changed"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,913
Messages
2,570,027
Members
46,421
Latest member
WaylonBran

Latest Threads

Top