asp.net 下拉列表無級(jí)數(shù)據(jù)綁定實(shí)現(xiàn)代碼
更新時(shí)間:2010年10月20日 19:51:06 作者:
asp.net 下拉列表無級(jí)數(shù)據(jù)綁定實(shí)現(xiàn)代碼,需要的朋友可以參考下。
復(fù)制代碼 代碼如下:
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)用
程序代碼
復(fù)制代碼 代碼如下:
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通用無刷新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從后臺(tái)控制器傳遞數(shù)據(jù)到前臺(tái)視圖的方式
這篇文章主要介紹了ASP.NET中MVC從后臺(tái)控制器傳遞數(shù)據(jù)到前臺(tái)視圖的方式,以實(shí)例形式較為詳細(xì)的分析了asp.net中MVC數(shù)據(jù)傳遞的具體實(shí)現(xiàn)方法,需要的朋友可以參考下2014-12-12動(dòng)態(tài)加載用戶控件至DataList并為用戶控件賦值實(shí)例演示
本文借用使用通用的新聞例子演示動(dòng)態(tài)加載用戶控件至DataList并為用戶控件賦值,感興趣的朋友可以了解下2013-01-01.Net Core實(shí)現(xiàn)健康檢查的示例代碼
這篇文章主要介紹了.Net Core實(shí)現(xiàn)健康檢查的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11asp.net 頁(yè)面延時(shí)五秒,跳轉(zhuǎn)到另外的頁(yè)面
asp.net 頁(yè)面延時(shí)五秒,跳轉(zhuǎn)到另外的頁(yè)面的實(shí)現(xiàn)代碼。2009-12-12深入Lumisoft.NET組件開發(fā)碰到亂碼等問題的解決方法
本篇文章介紹了,在Lumisoft.NET組件開發(fā)中碰到亂碼等一些問題的解決方法。需要的朋友參考下2013-05-05