Format DropDownList.TextValue

后端 未结 7 1542
失恋的感觉
失恋的感觉 2020-12-15 10:54

My stored procedure is like this

SELECT Id, StudentName
FROM xyz

I have a drop down list in asp.net, which I am loading as :



        
7条回答
  •  有刺的猬
    2020-12-15 11:42

    If you have list of class to fill drop down list, this is probably best to do;

    List foo = new List();
    
    ddlFoo.DataSource = foo.Select(x => 
        new ListItem { Text = x.Text1 + " - " + x.Text2, Value = x.Id.ToString() });
    ddlFoo.DataBind(); 
    

提交回复
热议问题