Handling events in a datagrid

Discussion in 'ASP .Net Datagrid Control' started by Deepak, Jun 30, 2003.

  1. Deepak

    Deepak Guest

    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
     
    Deepak, Jun 30, 2003
    #1
    1. Advertising

  2. Deepak

    Saravana Guest

    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"



    --
    Saravana
    Microsoft India Community Star,
    MCAD,SE,SD,DBA.


    "Deepak" <> wrote in message
    news:#...
    > 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
    >
    >
    >
    >
     
    Saravana, Jun 30, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shiv
    Replies:
    0
    Views:
    509
  2. Alvin Bruney
    Replies:
    1
    Views:
    747
  3. =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=

    order of events - dynamic checkbox events

    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=, Aug 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    595
    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=
    Aug 17, 2005
  4. Scott M.

    Handling Events Of DataGrid Template Item Controls - UNANSWERED

    Scott M., Nov 15, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    5
    Views:
    220
    Steven Cheng[MSFT]
    Nov 16, 2004
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    419
    Chris
    Aug 30, 2005
Loading...

Share This Page