在gridview asp net c中禁用buttonfield# [英] disable buttonfield in gridview asp net c#

查看:81
本文介绍了在gridview asp net c中禁用buttonfield#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <   asp:GridView     ID   =  GrdScanDoc     runat   =  server    AutoGenerateColumns   =  False    DataKeyNames   =  DocumentID  

EmptyDataText = 找不到记录 OnRowCommand = GrdScanDoc_RowCommand

onrowdatabound = GrdScanDoc_RowDataBound >
< >
< asp:TemplateField HeaderText = S.No >
< itemtemplate >
< asp:标签 ID = Label1 runat = server 文本 =' <% #Container.DataItemIndex + 1 %> ;' >
< / itemtemplate >

< asp:TemplateField HeaderText = 文档 >
< itemtemplate >
< a href = <% #Eval( 路径)%> style = 颜色:黑色; title = target = _blank >
< asp:标签 ID = lblScanDoc runat = server 文本 =' <% #Eval( DocumentName)%> ;' CssClass = FontEnglish

< span class =code-attribute>字体大小 = >
< / a >
< / itemtemplate >


< asp:ButtonField CommandName = 删除 文字 = < span class =code-keyword>删除 >
< item style width = 50px cssclass = FontEnglish / >

< / colum ns >

解决方案

尝试 Google [ ^ ] to得到你的答案。顶部链接:

hide-disable-commandfield-gridview [ ^ ]


您可以参考下面的代码:



  protected   void  GrdView_RowDataBound( object  sender,GridViewRowEventArgs e)
{
按钮btn =(按钮)e.Row.FindControl( YourbtnControlID); // 给出按钮表单模板字段的属性id
btn.Enabled = false // 或根据条件使用为启用按钮为true
}


不完全但尝试下面的代码

  protected   void  GrdView_RowDataBound( object  sender,GridViewRowEventArgs e)
{
Button btn =(Button)e.Row.Cell [ 1 ]; // 1是Bind按钮索引
btn.Enabled = false //
}


<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>

解决方案

Try Google[^] to get your answers. Top link being:
hide-disable-commandfield-gridview[^]


You can refer below code :

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
    }


Not exactly but try below code

protected void GrdView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        Button btn = (Button)e.Row.Cell[1]; // 1 is Bind button index
		btn.Enabled = false //
    }


这篇关于在gridview asp net c中禁用buttonfield#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆