Handling events in a datagrid

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Handling events in a datagrid

    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 Guest

  2. Similar Questions and Discussions

    1. Handling Events Of DataGrid Template Item Controls - UNANSWERED
      If I place a checkbox control into a template column of a DataGrid, how do I gain access to the CheckChanged event handler procedure that...
    2. Events Handling Order
      Hi all, I'm a total newbie, so this might be stupid... Anyway, I've created an expanding tree of categories control, based on DataList. It works...
    3. (vb.net) Handling user-control events
      I created a web-project containg an .aspx file and a self- made User-Control (.acsx file) - all in vb.net. My aspx file contains a Submit button...
    4. Handling events in container controls?
      Hi, I have a sub in a user control that looks like this: Public Sub BatchDetail_ItemCommand(ByVal Sender As Object, ByVal e As...
    5. Handling Events in Nested Controls
      Hi, I have nested User Controls like below. User_Control_1 User_Control_11 User_Control_12(contains method DisplayMessage) ...
  3. #2

    Default Re: Handling events in a datagrid

    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" <deepakvi@anz.com> wrote in message
    news:#W9sz9uPDHA.2768@tk2msftngp13.phx.gbl...
    > 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139