第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在GridView的TemplateField中找到控件?

如何在GridView的TemplateField中找到控件?

C#
繁星點(diǎn)點(diǎn)滴滴 2019-10-21 13:01:31
如何FindControl方法的工作,如果我需要找到任何Control這里面GridView Template,更具體ItemTemplate?我有一個(gè),hyperlink但找不到它。問題已用代碼更新GridView 代碼如下:<asp:GridView ID="grvYourOpportunities" runat="server" AllowPaging="True" AutoGenerateColumns="False"        DataKeyNames="ID#,B,H" PageSize="20" CellPadding="4" ForeColor="#333333" GridLines="Both"        OnRowDataBound="grvYourOpt_RowDataBound">        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />        <Columns>          <asp:TemplateField>                <HeaderTemplate>                    i                </HeaderTemplate>                <ItemTemplate>                    <%# Eval("i") %>                </ItemTemplate>            </asp:TemplateField>            <asp:TemplateField>                <HeaderTemplate>                    H                </HeaderTemplate>                <ItemTemplate>                    <%--<a href="javascript:ShowChildGrid('div<%# Eval("ID#") %>');">                    <img id="imgdiv<%# Eval("ID#") %>" alt="Click" border="0" src="plus.gif" runat="server" />  </a>  --%>                    <asp:HyperLink runat="server" ID="hlPlus" ImageUrl="~/plus.gif"></asp:HyperLink>                </ItemTemplate>            </asp:TemplateField>            <asp:TemplateField>                <HeaderTemplate>RowDataBound父母的事件GridView如下。如何FindControl方法的工作,如果我需要找到任何Control這里面GridView Template,更具體ItemTemplate?
查看完整描述

3 回答

?
ITMISS

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超8個(gè)贊

嘗試這個(gè):


foreach(GridViewRow row in GridView1.Rows) {

    if(row.RowType == DataControlRowType.DataRow) {

        HyperLink myHyperLink = row.FindControl("myHyperLinkID") as HyperLink;

    }

}

如果要處理RowDataBound事件,則如下所示:


protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

    if(e.Row.RowType == DataControlRowType.DataRow)

    {

        HyperLink myHyperLink = e.Row.FindControl("myHyperLinkID") as HyperLink;

    }

}


查看完整回答
反對 回復(fù) 2019-10-21
?
暮色呼如

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超9個(gè)贊

您可以使用此代碼HyperLink在GridView中查找。用于e.Row.Cells[0].Controls[0]在GridView中查找控件的第一個(gè)位置。


protected void AspGrid_RowDataBound(object sender, GridViewRowEventArgs e)

{    

  if(e.Row.RowType == DataControlRowType.DataRow)

    {

        DataRowView v = (DataRowView)e.Row.DataItem;           


        if (e.Row.Cells.Count > 0 && e.Row.Cells[0] != null && e.Row.Cells[0].Controls.Count > 0)

        {

            HyperLink link = e.Row.Cells[0].Controls[0] as HyperLink;

            if (link != null)

            {                    

                    link.Text = "Edit";

            }               

        }       


    }

}


查看完整回答
反對 回復(fù) 2019-10-21
?
慕森王

TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超3個(gè)贊

我已經(jīng)完成了訪問單元格控件內(nèi)的控件的操作。在所有控件集合中查找。


 ControlCollection cc = (ControlCollection)e.Row.Controls[1].Controls;


 Label lbCod = (Label)cc[1];


查看完整回答
反對 回復(fù) 2019-10-21
  • 3 回答
  • 0 關(guān)注
  • 659 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)