4
Answers

grid view

srinath

srinath

14y
2k
1
hi,

 I am trying to edit the row in the grid view, where i have a radiobuttonlist with three radio buttons. radiobuttonlist should not be edited when we click on edit but should be displayed. I tried to find the control and give the property but I could find the control. please help me...

thanks in advance.

Answers (4)
0
Dipa Ahuja

Dipa Ahuja

NA 4.1k 612.6k 14y
0
srinath

srinath

NA 133 0 14y

thanks for replying.

Actually, what i need to do is --

I have a gridview, in that I placed radiobuttonlist with three radio buttons and text box.
when I check the two  radio buttons,  the text should be enabled and for another radiobutton, textbox must be disabled.

I wrote the code but it's not working


              <asp:TemplateField HeaderText="DD PaidStatus" Visible="True" >
               <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server"  Enabled="false"  Visible ="false" Text='<%# Bind("PaidStatus") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="lblpaidstatus" runat="server" Text='<%# Bind("PaidStatus") %>' Visible="False"></asp:Label>
                    <asp:RadioButtonList ID="rblist11" runat="server"  RepeatDirection ="Horizontal" Enabled ="true" AutoPostBack="false" DataMember="PaidStatus" DataValueField="PaidStatus"  OnSelectedIndexChanged = "rblist11_SelectedIndexChanged" >
                         <asp:ListItem Value="1">Paid</asp:ListItem>
                         <asp:ListItem Selected="True" Value="0">NotPaid</asp:ListItem>
                         <asp:ListItem Value="2">Exempted</asp:ListItem>
                     </asp:RadioButtonList>
                </ItemTemplate>
            </asp:TemplateField>
           
            <asp:TemplateField HeaderText="Amount">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Amount") %>' ></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Amount") %>' Visible="False"></asp:Label>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Amount") %>' Width="59px"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>



protected void rblist11_SelectedIndexChanged(object sender, EventArgs e)
    {
      foreach (GridViewRow item in GridView1.Rows)
      {

          RadioButtonList rbl = item.FindControl("rblist11") as RadioButtonList;
          TextBox txtamount = item.FindControl("TextBox3") as TextBox;
          if (rbl.SelectedItem.Value == "0")
                    {                                         
                        txtamount.Enabled = false;
                   
                    }
                    else if ((rbl.SelectedItem.Value == "1") || (rbl.SelectedItem.Value == "2"))
                    {
                        txtamount.Enabled = true;
                    }

         }
}


plz help me..





0
Dipa Ahuja

Dipa Ahuja

NA 4.1k 612.6k 14y
hi...

in gridview if your radiobuttons are non-editable then write them in ItemTemplate this way

<asp:TemplateField  HeaderText="Select">               
                 <ItemTemplate>
                     <RadioButtonID="cb" runat="server" />
                 </ItemTemplate>
            </asp:TemplateField>

if it help you mark my answer
0
srinath

srinath

NA 133 0 14y


plz reply me