English 中文(简体)
如何使用模板 《刑法》中的领域
原标题:How to Access TemplateField in Code Behind [closed]

要求制定法典的问题必须 尽可能了解正在解决的问题。 包括尝试性解决办法,为什么他们做t工作,以及expected 结果。 另见:。 排出问题清单

Closed 10 years ago.

<asp:DetailsView...
    <asp:TemplateField HeaderText="My CheckBox" SortExpression="DataID" >
         <InsertItemTemplate>
                <asp:CheckBox ID="T01cbx" runat="server" Visible ="false" Checked= <%# Bind("DataID") %>  AutoPostBack="True" " />
         </InsertItemTemplate>
    </asp:TemplateField>

我想为上述模板现场提供身份证或名称,并从后面的代码中获取。 是否有任何途径通过提供和识别或姓名来寻找模板现场? 这在《详细意见》中。

最佳回答

您可使用LINQ获取Template Field,由HeaderText:

TemplateField cbField = DetailsView1.Fields.OfType<TemplateField>()
                       .Where(f => f.HeaderText == "My CheckBox")
                       .FirstOrDefault();
问题回答

我过去曾试图这样做,但从来没有找到比书写一种功能更好的方法,这种功能 lo开了所有各栏,并找到希望通过压缩加以修改的栏目。

它是用于隐藏/how栏的:

public void ShowHideGridColumnBySortExpression(string sortExpression, bool show)
{
    for (int i = 0; i < gvProducts.Columns.Count; i++)
    {
        if (gvProducts.Columns[i].SortExpression != null && gvProducts.Columns[i].SortExpression == sortExpression)
        {
            gvProducts.Columns[i].Visible = show;
            break;
        }
    }
}




相关问题
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!