我有一個標籤,在Itemtemplate中,我想獲得標籤的值,但 只是找不到控件的標籤,請有人幫助我?謝謝如何獲取標籤位於ItemTemplate中C#代碼後面的標籤?
ASPX代碼:
<asp:TemplateField HeaderText="工號" SortExpression="BS_ID"> <ItemTemplate> <asp:Label ID="lblBSID" runat="server" Text='<%# Eval("BS_ID") %>' /> </ItemTemplate> <EditItemTemplate> <asp:Textbox ID="tbBS_ID_edit" runat="server" Text='<%# Eval("BS_ID") %>' /> </EditItemTemplate> <FooterTemplate> <asp:TextBox ID="BS_ID_tb" Text="SK" MaxLength="7" runat="server" /> </FooterTemplate> </asp:TemplateField>
代碼
- 這是我VAR
//string lb_BS_ID = ((Label)GridView1.FindControl("lblBSID")).Text; //this._userID = lb_BS_ID;
- ,我也嘗試
- 此外
//string lb_BS_ID = ((Label)GridView1.Rows[0].FindControl("lblBSID")).Text; //this._userID = lb_BS_ID;
//string lb_BS_ID =((Label)GridView1.Rows[e.RowIndex].Cells[0]FindControl("lblBSID")).Text; //this._userID = lb_BS_ID;
但這些都是不適合我,請幫助我工作> <
對不起兄弟你不能訪問任何CNTROL,我忘了說我已經嘗試過了......而且這不起作用T_T – Woody
你介意給我回答一個問題嗎?當我開始我var一個私人字符串_userID,我通過文本框插入數據到數據庫後,_userID值變爲null,這是正常的? – Woody
如果是正常的,在插入數據庫之後如何存儲_userID之類的值?@@ – Woody