asp.net 下拉列表無(wú)級(jí)數(shù)據(jù)綁定實(shí)現(xiàn)代碼
private string toadd = "├".<BR><BR>private void GetArticleCategory(string pid)
{
SqlConnection conn = new SqlConnection("server=.;database=test;uid=sa;pwd=;");
string sql = "select Articlesgroup_id,Groupname from Articlesgroup where Articlesgroup_parent_id=@pid order by Groupname";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlParameter Pid = new SqlParameter("@pid", SqlDbType.Int);
Pid.Value = pid;
cmd.Parameters.Add(Pid);
conn.Open();
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
this.DropDownList1.Items.Add(new ListItem(toadd + " " + sdr[1].ToString(), sdr[0].ToString()));
toadd += "─┴";
this.GetArticleCategory(sdr[0].ToString());
toadd = toadd.Substring(0, toadd.Length - 2);
}
sdr.Close();
conn.Close();
}
在Page_Load里調(diào)用
程序代碼
protected void Page_Load(object sender, EventArgs e)
{
this.keyword.Attributes.Add("onfocus","if( this.value=='key key key') {this.value='' };");
if (!Page.IsPostBack)
{
this.GetArticleCategory("0");
}
this.DropDownList1.Items.Insert(0, new ListItem("Search All", "all"));
}
- ASP.NET MVC DropDownList數(shù)據(jù)綁定及使用詳解
- AspNetAjaxPager,Asp.Net通用無(wú)刷新Ajax分頁(yè)控件,支持多樣式多數(shù)據(jù)綁定
- asp.net ListView 數(shù)據(jù)綁定
- asp.net Repeater 數(shù)據(jù)綁定的具體實(shí)現(xiàn)(圖文詳解)
- asp.net Repeater 數(shù)據(jù)綁定代碼
- asp.net數(shù)據(jù)綁定DataBind使用方法
- ASP.NET Eval進(jìn)行數(shù)據(jù)綁定的方法
- ASP.NET框架中的數(shù)據(jù)綁定概要與數(shù)據(jù)綁定表達(dá)式的使用
相關(guān)文章
Asp.net MVC 中利用jquery datatables 實(shí)現(xiàn)數(shù)據(jù)分頁(yè)顯示功能
這篇文章主要介紹了Asp.net MVC 中利用jquery datatables 實(shí)現(xiàn)數(shù)據(jù)分頁(yè)顯示功能,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-06-06
在DataTable中執(zhí)行Select("條件")后,返回DataTable的方法
在DataTable中執(zhí)行Select("條件")后,返回DataTable的方法...2007-09-09
asp.net下數(shù)據(jù)庫(kù)操作優(yōu)化一例
數(shù)據(jù)庫(kù)升級(jí),需要對(duì)幾個(gè)表進(jìn)行一些數(shù)據(jù)轉(zhuǎn)換,具體是這樣:針對(duì)每一個(gè) Item,從 orders 表里查出 Shop_Id,并把此 Id 賦值給 items 和 skus 中的 Shop_Id。2010-11-11
.NET發(fā)送郵件的實(shí)現(xiàn)方法示例
這篇文章主要給大家介紹了關(guān)于.NET發(fā)送郵件的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用.net具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-06-06
ajaxpro.dll 控件實(shí)現(xiàn)異步刷新頁(yè)面
用ajaxpro.dll控件實(shí)現(xiàn)異步刷新頁(yè)面的代碼,需要的朋友可以參考下。2009-11-11
Asp.net的應(yīng)用程序?qū)ο蠛晚?yè)面生存周期
Asp.net的應(yīng)用程序?qū)ο蠛晚?yè)面生存周期,需要的朋友可以參考一下2013-02-02
基于.NET?7?的?QUIC?實(shí)現(xiàn)?Echo?服務(wù)的詳細(xì)過(guò)程
這篇文章主要介紹了基于.NET?7?的?QUIC實(shí)現(xiàn)Echo服務(wù),下面的內(nèi)容中,我會(huì)介紹如何在.NET?中使用?Quic,文中結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-11-11
如何取得Repeater控件選擇的項(xiàng)目及注意事項(xiàng)
Repeater控件,每個(gè)item前有一個(gè)CheckBox,把選擇的item列顯出來(lái),有兩個(gè)地方需要注意的,就是CheckBox與Label,這個(gè)Label是隨你需要獲取的內(nèi)容而變化喔。如你想獲取Nickname,那你需要把綁定的的內(nèi)容放在Label上2013-01-01

