Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have grid with 3 column, one is filled with Sno, and other two has Textboxes in it for the user to enter the text.
I have used this code to change the active row color. But the problem i am facing is i cant type in the textboxes.

Please advice any other suitable way. or do i need to change anything in the code.

C#
protected override void Render(System.Web.UI.HtmlTextWriter writer)
   {
       foreach (GridViewRow row in GridviewSample.Rows)
       {
           if (row.RowType == DataControlRowType.DataRow)
           {
               row.Attributes["onmouseover"] =
                  "this.style.cursor='hand';this.style.textDecoration='underline';";
               row.Attributes["onmouseout"] =
                  "this.style.textDecoration='none';";
               // Set the last parameter to True
               // to register for event validation.
               row.Attributes["onclick"] =
               ClientScript.GetPostBackClientHyperlink(GridviewSample,
                  "Select$" + row.DataItemIndex, true);
           }
       }
       base.Render(writer);
   }


and this is my gridview.

XML
<asp:GridView ID="GridviewSample" runat="server" AutoGenerateColumns="false"
        onselectedindexchanged="GridviewSample_SelectedIndexChanged"
        onselectedindexchanging="GridviewSample_SelectedIndexChanging"
        SelectedRowStyle-BackColor="LightGray" ondatabound="GridviewSample_DataBound"  >
    <Columns>
     <asp:BoundField DataField="SNo" HeaderText="SNo" />
    <asp:TemplateField HeaderText="Name">
    <ItemTemplate >
     <asp:TextBox ID="txtname" runat="server" ></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateField>
     <asp:TemplateField HeaderText="Age">
    <ItemTemplate >
     <asp:TextBox ID="txtage" runat="server" ></asp:TextBox>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
Posted
Updated 19-Dec-12 0:38am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900