詳解asp.net控件CheckBoxList的使用_.Net教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:解析TABLE導(dǎo)入到EXCEL前臺(tái)代碼:ExportExcel1.aspx %@PageLanguage=C#AutoEventWireup=trueCodeFile=ExportExcel1.aspx.csInherits=ExportExcel1% EhtmlPUBLIC-//W3C//DTDXHTML1.0xhtml1-transitional.dtd ht
< asp:CheckBoxList ID = "cblJL" runat = "server" RepeatDirection="Horizontal" Width="100%">< asp:ListItem>當(dāng)前記錄asp:ListItem>
< asp:ListItem>當(dāng)前頁(yè)asp:ListItem>
< asp:ListItem>全部記錄asp:ListItem>
< /asp:CheckBoxList>
后臺(tái)3種方式:
第一種:獲得CheckBox的值
C#代碼
string save_cblJL = "";
for (int i = 0; i < this.cblJL.Items.Count; i++)
{
if (this.cblJL.Items[i].Selected == true)
{
save_cblJL += this.cblJL.Items[i].Value + ",";
}
}
Response.Write(save_cblJL);
string save_cblJL = "";
for (int i = 0; i < this.cblJL.Items.Count; i++)
{
if (this.cblJL.Items[i].Selected == true)
{
save_cblJL += this.cblJL.Items[i].Value + ",";
}
}
Response.Write(save_cblJL);
第二種:獲得CheckBox的值
C#代碼
string str_Save_cblJL = "";
foreach (ListItem li in cblJL.Items)
{
if (li.Selected == true)
{
str_Save_cblJL += li.Value + ",";
}
}
Response.Write(str_Save_cblJL);
string str_Save_cblJL = "";
foreach (ListItem li in cblJL.Items)
{
if (li.Selected == true)
{
str_Save_cblJL += li.Value + ",";
}
}
Response.Write(str_Save_cblJL);
第三種:從后臺(tái)給前臺(tái)CheckBox賦值
C#代碼
string strapp = "當(dāng)前記錄,當(dāng)前頁(yè),全部記錄,";
string[] strtemp = strapp.Split(’,’);
foreach (string str in strtemp)
{
for (int i = 0; i < cblJL.Items.Count; i++)
{
if (this.cblJL.Items[i].Value == str)
{
this.cblJL.Items[i].Selected = true;
}
}
}
分享:解析ASP.NET頁(yè)面數(shù)據(jù)導(dǎo)出到Excel或WordprivatevoidbtnMIME_Click(objectsender,System.EventArgse) { BindData(); Response.ContentType=application/vnd.ms-Excel; Response.AddHeader(Content-Disposition,inline;filename= +HttpUtility.UrlEncode(下載文件.xls,Encoding.UTF8)); //如
相關(guān).Net教程:
- asp.net如何得到GRIDVIEW中某行某列值的方法
- .net SMTP發(fā)送Email實(shí)例(可帶附件)
- js實(shí)現(xiàn)廣告漂浮效果的小例子
- asp.net Repeater 數(shù)據(jù)綁定的具體實(shí)現(xiàn)
- Asp.Net 無(wú)刷新文件上傳并顯示進(jìn)度條的實(shí)現(xiàn)方法及思路
- Asp.net獲取客戶端IP常見(jiàn)代碼存在的偽造IP問(wèn)題探討
- VS2010 水晶報(bào)表的使用方法
- ASP.NET中操作SQL數(shù)據(jù)庫(kù)(連接字符串的配置及獲取)
- asp.net頁(yè)面?zhèn)髦禍y(cè)試實(shí)例代碼
- DataGridView - DataGridViewCheckBoxCell的使用介紹
- asp.net中javascript的引用(直接引入和間接引入)
- 三層+存儲(chǔ)過(guò)程實(shí)現(xiàn)分頁(yè)示例代碼
.Net教程Rss訂閱編程教程搜索
.Net教程推薦
- ASP.NET MVC是怎樣實(shí)現(xiàn)自己的視圖引擎的
- 解析ASP.NET頁(yè)面數(shù)據(jù)導(dǎo)出到Excel或Word
- .NET2.0抓取網(wǎng)頁(yè)全部鏈接
- 在客戶端驗(yàn)證密碼強(qiáng)度[2],兼容FireFox和IE
- 在ASP.NET Atlas中調(diào)用Web Service
- 揭秘.Net開(kāi)發(fā)人員必知的八個(gè)網(wǎng)站
- Asp.Net編程基礎(chǔ)經(jīng)驗(yàn)技巧總結(jié)
- 淺談ASP.NET2.0中配置文件的加密與解密
- 揭秘設(shè)計(jì)ASP.NET應(yīng)用程序的七大妙招
- 將一個(gè)圖片按比例縮放顯示在一個(gè)Frame中
- 相關(guān)鏈接:
- 教程說(shuō)明:
.Net教程-詳解asp.net控件CheckBoxList的使用
。