English 中文(简体)
A. 如何在项目表内为单个栏目提供可拆解的物项
原标题:How to disable items inside the ItemTemplate for a individual columns in asp.net
 <Columns>
                        <asp:TemplateField HeaderText="Actions" ItemStyle-Width="15%">
                            <ItemTemplate>
                                <asp:ImageButton ID="imgbtn" ImageUrl="Styles/Images/Edit.jpg" runat="server" Width="25"
                                    Height="25" OnClick="imgbtn_MessageEditClick" Enabled="True" ToolTip="Edit Message" />
                                <asp:LinkButton ID="Lnk_Delete"  CommandArgument= <%# Eval("MsgID") %> 
                                    CommandName="Delete" runat="server" >                                        <img id="Img1" src="Styles/Images/Delete.jpg" runat="server" style="border-style: none"
                                        alt="Delete Message" /></asp:LinkButton>
                                <asp:ImageButton ID="imgbtn_ViewDashBoard" ImageUrl="Styles/Images/dash.jpg" Enabled="True"
                                    Width="" runat="server" PostBackUrl= <%# Eval("MsgID", "ResponseMetric.aspx?MsgID={0}") %> 
                                    Text= Send  ToolTip="View DashBoard"></asp:ImageButton>
                            </ItemTemplate>

我有这些项目模板,列在同一个栏中,我还有另一个一栏宣传。 在<代码>rowDataBound中,如果电文是 当时我没有把“滚珠”改为“红色”,对于同一栏,我如何在<条码>内找到“可操作的>>。

protected void MyGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        System.Web.UI.WebControls.Image img = (System.Web.UI.WebControls.Image)e.Row.FindControl("Status");
        int msgid;
        int.TryParse(Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MsgID")), out msgid);            
        string status = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MessageActive"));
        if(status.Equals("No"))
        {
            e.Row.BackColor = Color.Red;

        } 
      }
    }

页: 1

最佳回答
ImageButton btnEdit = (ImageButton)e.Row.FindControl("imgbtn");
btnEdit.Enabled = !status.Equals("No");
LinkButton btnDelete = (LinkButton)e.Row.FindControl("Lnk_Delete");
btnDelete.Enabled = !status.Equals("No");
问题回答

您可在罗达塔·博迪活动手法中添加以下代码:

    ImageButton imgBtn = e.Row.FindControl("imgbtn") as ImageButton;
    LinkButton lnkBtn = e.Row.FindControl("Lnk_Delete") as LinkButton;


    if (null != imgBtn)
        imgBtn.Enabled = false;

    if (null != lnkBtn)
        lnkBtn.Enabled = false;




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签