asp.net 下拉列表無級數(shù)據(jù)綁定實現(xiàn)代碼
更新時間:2010年10月20日 19:51:06 作者:
asp.net 下拉列表無級數(shù)據(jù)綁定實現(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分頁控件,支持多樣式多數(shù)據(jù)綁定
- asp.net ListView 數(shù)據(jù)綁定
- asp.net Repeater 數(shù)據(jù)綁定的具體實現(xiàn)(圖文詳解)
- asp.net Repeater 數(shù)據(jù)綁定代碼
- asp.net數(shù)據(jù)綁定DataBind使用方法
- ASP.NET Eval進行數(shù)據(jù)綁定的方法
- ASP.NET框架中的數(shù)據(jù)綁定概要與數(shù)據(jù)綁定表達式的使用
相關(guān)文章
ASP.NET中MVC從后臺控制器傳遞數(shù)據(jù)到前臺視圖的方式
這篇文章主要介紹了ASP.NET中MVC從后臺控制器傳遞數(shù)據(jù)到前臺視圖的方式,以實例形式較為詳細的分析了asp.net中MVC數(shù)據(jù)傳遞的具體實現(xiàn)方法,需要的朋友可以參考下2014-12-12
動態(tài)加載用戶控件至DataList并為用戶控件賦值實例演示
本文借用使用通用的新聞例子演示動態(tài)加載用戶控件至DataList并為用戶控件賦值,感興趣的朋友可以了解下2013-01-01
asp.net 頁面延時五秒,跳轉(zhuǎn)到另外的頁面
asp.net 頁面延時五秒,跳轉(zhuǎn)到另外的頁面的實現(xiàn)代碼。2009-12-12
深入Lumisoft.NET組件開發(fā)碰到亂碼等問題的解決方法
本篇文章介紹了,在Lumisoft.NET組件開發(fā)中碰到亂碼等一些問題的解決方法。需要的朋友參考下2013-05-05

