Click here to Skip to main content
16,020,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASP.NET
<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>
Posted
Updated 23-Apr-13 21:21pm
v4

Not exactly but try below code
C#
protected void GrdView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        Button btn = (Button)e.Row.Cell[1]; // 1 is Bind button index
		btn.Enabled = false //
    }
 
Share this answer
 
v2
Comments
satpal 2 24-Apr-13 3:05am    
Not working..giving error..

can not convert table cell to button
Chetan Tembhre 25-Apr-13 1:25am    
System.Web.UI.WebControls.Button btn = (System.Web.UI.WebControls.Button)e.Row.Cells[1].Controls[1];
btn.Enabled = false;
You can refer below code :

C#
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
    }
 
Share this answer
 
Comments
satpal 2 24-Apr-13 2:35am    
Chetan ,i improve question and put a sample code there where i want to disable following column

<asp:ButtonField CommandName="Delete" Text="Remove">
Member 14743579 8-Apr-20 13:38pm    
how can i block a row data on gridview as per my choice
Try Google[^] to get your answers. Top link being:
hide-disable-commandfield-gridview[^]
 
Share this answer
 
Comments
_Amy 24-Apr-13 3:22am    
5'ed.
Vani Kulkarni 24-Apr-13 3:51am    
Thanks Amy.

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