How to enable column in GridView?

aytachb

New Member
I've a ASP.NET GridView with the following data:
5LCUw.jpg
Rows will be disable OnRowDataBound based on the value on column3.GridView : \[code\]<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" onrowdatabound="GridView1_RowDataBound1"> <Columns> <asp:TemplateField HeaderText="Column1"> <ItemTemplate> <asp:HyperLink ID="hyperlink" runat="server" Text='<% #Eval("Dosage") %>' NavigateUrl='<% #Eval("Dosage") %>'></asp:HyperLink> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Column2"> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<% #Eval("Drug") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Column3"> <ItemTemplate> <asp:Label ID="Label3" runat="server" Text='<% #Eval("Patient") %>' ></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Column4"> <ItemTemplate> <asp:Label ID="Label4" runat="server" Text='<% #Eval("Date") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>\[/code\]RowDataBound :\[code\]protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { Label a = e.Row.FindControl("Label3") as Label; if (a.Text == "Sam") { e.Row.Enabled = false; e.Row.Cells[0].Enabled = true; } }}\[/code\]however, I want column1 always enable, hyperlink in column1 should always clickable.I've tried get the cells and enabled it, but it is not working.kindly advise what is the workaround for the issue above.
 
Back
Top