<asp:GridView ID="GrdScanDoc" runat="server" AutoGenerateColumns="False" DataKeyNames="DocumentID" EmptyDataText="No Record Found" OnRowCommand="GrdScanDoc_RowCommand" onrowdatabound="GrdScanDoc_RowDataBound"> <columns> <asp:TemplateField HeaderText="S.No"> <itemtemplate> <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex + 1%>'> </itemtemplate> <asp:TemplateField HeaderText="Document"> <itemtemplate> <a href="<%# Eval("Path") %>" style="color: Black;" title="" target="_blank"> <asp:Label ID="lblScanDoc" runat="server" Text='<%# Eval("DocumentName") %>' CssClass="FontEnglish" Font-Size="Small"> </a> </itemtemplate> <asp:ButtonField CommandName="Delete" Text="Remove"> <itemstyle width="50px" cssclass="FontEnglish" /> </columns>
protected void GrdView_RowDataBound(object sender, GridViewRowEventArgs e) { Button btn = (Button)e.Row.Cell[1]; // 1 is Bind button index btn.Enabled = false // }
protected void GrdView_RowDataBound(object sender, GridViewRowEventArgs e) { Button btn = (Button)e.Row.FindControl("YourbtnControlID"); // give property id of button form template field btn.Enabled = false // or used true for enabled button basis on condition }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)