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

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

asp.net 在GridView EditItemTemplate模版里獲取控件

asp.net 在GridView EditItemTemplate模版里獲取控件

慕的地8271018 2018-12-06 21:12:31
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="100%" CellPadding="4" ForeColor="#333333" GridLines="None" onrowediting="GridView1_RowEditing" DataKeyNames="com_id" onrowcommand="GridView1_RowCommand" onrowdatabound="GridView1_RowDataBound" onrowupdated="GridView1_RowUpdated" onrowcreated="GridView1_RowCreated"> <RowStyle BackColor="#EFF3FB" /> <Columns> <asp:TemplateField HeaderText="編號(hào)"> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text="Label"><%# Eval("com_num") %></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="公司名"> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text="Label"><%# Eval("company_name") %></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="狀態(tài)"> <ItemTemplate> <asp:Label ID="Label3" runat="server" Text="Label"><%# Eval("status") %></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </EditItemTemplate> </asp:TemplateField> <asp:CommandField ShowEditButton="True" HeaderText="編輯" /> <asp:BoundField /> </Columns> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#2461BF" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> 我想在???RowDataBound事件里查找?EditItemTemplate里的控件 動(dòng)態(tài)的給空間賦值? 可是怎么都找不到值 無語了 總是提示:未將對(duì)象因引用設(shè)置到對(duì)象的實(shí)力。 在網(wǎng)上的各種發(fā)放都試過了,每一個(gè)有用的? 請(qǐng)高人幫一下忙? ,小弟現(xiàn)在沒分了 ,有哪位高手愿意幫助一下, 謝謝了!
查看完整描述

2 回答

?
慕桂英546537

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

要想?RowDataBound時(shí)間找到?EditItemTemplate里的控件,必須點(diǎn)擊編輯按鈕執(zhí)行??

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
??????? {
??????????? GridView1.EditIndex = e.NewEditIndex;
??????????? LoadData();//此時(shí)綁定數(shù)據(jù)源時(shí)?RowDataBound事件函數(shù)能找到你的控件。
??????????? }

?private void LoadData()
??????? {
??????????? GridView1.DataSource = GridViewClass.ReadData();
??????????? GridView1.DataBind();
??????? }

??????? protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
??????? {
??????????? GridView1.EditIndex = -1;
??????????? LoadData();
??????? }

??????? protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
??????? {
??????????? if (e.Row.RowType == DataControlRowType.DataRow)
??????????? {

????????????? //要想找到控件必須點(diǎn)擊EDIT按鈕重新綁定DataSource

???????????? ? TextBox txt = (TextBox)e.Row.FindControl("TextBox1");
??????????????? if (txt != null)
??????????????? {
??????????????????? txt.Text ="ggggg";
??????????????? }
??????????? }
??????? }

查看完整回答
反對(duì) 回復(fù) 2019-01-21
?
一只斗牛犬

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

模板列找控件關(guān)鍵FindControl

(e.Row.FindControl(要找的控件ID) as Textbox).Text

查看完整回答
反對(duì) 回復(fù) 2019-01-21
  • 2 回答
  • 0 關(guān)注
  • 1046 瀏覽

添加回答

舉報(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)