asp.net Repeater取得CheckBox選中的某行某個值的c#寫法
更新時間:2008年08月06日 13:06:21 作者:
asp.net(c#)利用Repeater取得CheckBox選中行的某個值的代碼
1、
foreach (Control c in this.rptTables.Controls)
{
CheckBox cbx = (CheckBox)c.FindControl("cbxId");
TextBox tbx = (TextBox)c.FindControl("tbxTableName");
if (cbx != null)
{
if (cbx.Checked == true)
{
common.salert(tbx.Text);
}
}
}
2、
for (int i = 0; i < this.rptTables.Items.Count; i++)
{
CheckBox cbx = (CheckBox)rptTables.Items[i].FindControl("cbxId");
TextBox tbx = (TextBox)rptTables.Items[i].FindControl("tbxTableName");
if (cbx != null)
{
if (cbx.Checked)
{
common.salert(tbx.Text);
}
}
}
關鍵點:在每行再寫個隱藏的控件我是用TextBox,代碼如下:
<asp:TextBox id="tbxTableName" runat="server" Text='<%#Eval("TABLE_NAME") %>' style="display:none;" />
foreach (Control c in this.rptTables.Controls)
{
CheckBox cbx = (CheckBox)c.FindControl("cbxId");
TextBox tbx = (TextBox)c.FindControl("tbxTableName");
if (cbx != null)
{
if (cbx.Checked == true)
{
common.salert(tbx.Text);
}
}
}
2、
for (int i = 0; i < this.rptTables.Items.Count; i++)
{
CheckBox cbx = (CheckBox)rptTables.Items[i].FindControl("cbxId");
TextBox tbx = (TextBox)rptTables.Items[i].FindControl("tbxTableName");
if (cbx != null)
{
if (cbx.Checked)
{
common.salert(tbx.Text);
}
}
}
關鍵點:在每行再寫個隱藏的控件我是用TextBox,代碼如下:
<asp:TextBox id="tbxTableName" runat="server" Text='<%#Eval("TABLE_NAME") %>' style="display:none;" />
相關文章
Windows Server 2012 R2 Standard搭建ASP.NET Core環(huán)境圖文教程
這篇文章主要介紹了Windows Server 2012 R2 Standard搭建ASP.NET Core環(huán)境圖文教程,需要的朋友可以參考下2016-07-07
ASP.NET MVC 4 中的JSON數(shù)據(jù)交互的方法
本篇文章主要介紹了ASP.NET MVC 4 中的JSON數(shù)據(jù)交互的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-04-04
asp.net post方法中參數(shù)取不出來的解決方法
調試client端調用web api的代碼,服務器端的post方法的參數(shù)死活取不出來,下面有個不錯的解決方法,希望對大家有所幫助2014-01-01
asp.net sql 數(shù)據(jù)庫處理函數(shù)命令
asp.net sql 數(shù)據(jù)庫處理函數(shù)命令 ,需要的朋友可以參考下。2009-10-10
在ASP.NET Core5.0中訪問HttpContext的方法步驟
這篇文章主要介紹了在ASP.NET Core5.0中訪問HttpContext的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-11-11

