国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

詳解asp.net控件CheckBoxList的使用_.Net教程

2024-07-10 12:51:53
字體:
供稿:網(wǎng)友

推薦:解析TABLE導(dǎo)入到EXCEL
前臺代碼: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)前頁asp:ListItem>    
    < asp:ListItem>全部記錄asp:ListItem>   
< /asp:CheckBoxList>   

后臺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);
第三種:從后臺給前臺CheckBox賦值 
C#代碼 
string strapp = "當(dāng)前記錄,當(dāng)前頁,全部記錄,";    
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頁面數(shù)據(jù)導(dǎo)出到Excel或Word
privatevoidbtnMIME_Click(objectsender,System.EventArgse) { BindData(); Response.ContentType=application/vnd.ms-Excel; Response.AddHeader(Content-Disposition,inline;filename= +HttpUtility.UrlEncode(下載文件.xls,Encoding.UTF8)); //如

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 象山县| 溧阳市| 毕节市| 阳春市| 阿勒泰市| 宁德市| 温宿县| 漠河县| 麦盖提县| 仲巴县| 常熟市| 平陆县| 社会| 双柏县| 三台县| 原阳县| 土默特右旗| 黎平县| 南阳市| 台江县| 都兰县| 莱西市| 岳阳市| 时尚| 鄂温| 镇巴县| 武威市| 呼伦贝尔市| 曲阜市| 邵阳市| 宿州市| 清河县| 都匀市| 黄石市| 梨树县| 抚松县| 卓资县| 广饶县| 朝阳市| 南通市| 镇原县|