开发者

dropdownlist binding

开发者 https://www.devze.com 2023-03-24 23:18 出处:网络
I was trying to bring all the database names in a dropdownlist.. Here is my code .. protected void Page_Load(object sender, EventArgs e)

I was trying to bring all the database names in a dropdownlist.. Here is my code ..

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
populateddl();
}
}

private void populateddl()
{
using (SqlDataAdapter sda = new SqlDataAdapter("exec sp_databases", conn))
{
using(DataSet ds = new DataSet())
{
sda.Fill(ds);
DropDownList8.DataSource = ds;
DropDownList8.DataBind();
}
}
}

em not able to get the names in the dropdownlist, pls help me in this scenario.. when run the application what em gett开发者_运维知识库ing is.. system.data.datarowview as items of dropdownlist instead of this i should get names of databases Looking forward for ur replys

Thanks & Regards,


aslo specify the column name of the Datasource to be displayed

DropDownList8.DataTextField ="DataFieldName"
DropDownList8.DataValueField="DataFieldName"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号