ListBox中怎么實(shí)現(xiàn)多選并顯示數(shù)據(jù),很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。
成都創(chuàng)新互聯(lián)一直在為企業(yè)提供服務(wù),多年的磨煉,使我們?cè)趧?chuàng)意設(shè)計(jì),網(wǎng)絡(luò)營(yíng)銷推廣到技術(shù)研發(fā)擁有了開(kāi)發(fā)經(jīng)驗(yàn)。我們擅長(zhǎng)傾聽(tīng)企業(yè)需求,挖掘用戶對(duì)產(chǎn)品需求服務(wù)價(jià)值,為企業(yè)制作有用的創(chuàng)意設(shè)計(jì)體驗(yàn)。核心團(tuán)隊(duì)擁有超過(guò)10多年以上行業(yè)經(jīng)驗(yàn),涵蓋創(chuàng)意,策化,開(kāi)發(fā)等專業(yè)領(lǐng)域,公司涉及領(lǐng)域有基礎(chǔ)互聯(lián)網(wǎng)服務(wù)服務(wù)器托管雅安、成都app軟件開(kāi)發(fā)公司、手機(jī)移動(dòng)建站、網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)絡(luò)整合營(yíng)銷。
<%@ Page Language="C#" AutoEventWireup="true" Debug="true"%>
<%@import namespace="System.Data"%>
<%@import namespace="System.Data.SqlClient"%>
<FORM RUNAT=< SPAN>"server">
"ckbEmployees" runat="server" RepeatLayout="table" RepeatDirection="vertical" RepeatColumns="3" CellPadding="9" CellSpacing="18" TextAlign="right" OnSelectedIndexChanged="subListChange" AutoPostBack="true" />
"dgEmployee" runat="server" />
<SCRIPT LANGUAGE=< SPAN>"c#" runat="server">
private void Page_load(object sender,System.EventArgs e)
{
if(!IsPostBack)
{
string strConnection ="server=.;uid=sa;pwd=sunix!;database=northwind";
string strSQLforCheckBoxes = "select LastName ,EmployeeID from employees order by lastname";
SqlConnection objConnection = new SqlConnection(strConnection);
SqlCommand objCommand = new SqlCommand(strSQLforCheckBoxes,objConnection);
objConnection.Open();
ckbEmployees.DataSource = objCommand.ExecuteReader();
ckbEmployees.DataTextField = "LastName";
ckbEmployees.DataValueField = "EmployeeID";
ckbEmployees.DataBind();
objConnection.Close();
}
}
private void subListChange(object s,System.EventArgs e)
{
Response.Write("subListchange triggered
");
string strWhereClause="";
foreach (ListItem liThisOne in ckbEmployees.Items)
{
if(liThisOne.Selected)
{
strWhereClause += "EmployeeID = " + liThisOne.Value + " OR ";
}
}
Response.Write("strWhereClause=
"+strWhereClause+"");
if(strWhereClause.Length>0)
{
dgEmployee.Visible = true;
string str = strWhereClause.Substring(0,strWhereClause.Length - 3);
strWhereClause = " where " + str;
string strConnection = "server=.;uid=sa;pwd=sunix!;database=northwind";
string strSQLforGrid = "select TitleOfCourtesy,firstName,lastName,country,region,city,notes from employees " + strWhereClause;
//Response.Write(strSQLforGrid); sql語(yǔ)句之間的空格,否則出錯(cuò)
SqlConnection objConnection = new SqlConnection(strConnection);
SqlCommand objCommand = new SqlCommand(strSQLforGrid,objConnection);
Response.Write("strSQLforGrid=
"+strSQLforGrid+"");
objConnection.Open();
dgEmployee.DataSource = objCommand.ExecuteReader();
dgEmployee.DataBind();
objConnection.Close();
}
else
{
dgEmployee.Visible = false;
}
}
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。
新聞標(biāo)題:ListBox中怎么實(shí)現(xiàn)多選并顯示數(shù)據(jù)
當(dāng)前URL:http://jinyejixie.com/article42/gggjec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、企業(yè)網(wǎng)站制作、移動(dòng)網(wǎng)站建設(shè)、做網(wǎng)站、網(wǎng)站營(yíng)銷、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)