日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

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

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:解析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)); //如

來源:模板無憂//所屬分類:.Net教程/更新時間:2010-02-25
相關(guān).Net教程