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 :
ddlA.DataSource = // Some source
ddlA.DataTextField = "Id" + " -" + "StudentName";
ddlA.DataValueField = "Id";
ddlA.DataBind();
ddlA.Items.Insert(0, new ListItem(" Select one", "0"));
But at the Databind()
statement, I am getting this error:
System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Id-StudentName'.
In text part of the dropdown list, I want to display the concatenated value of Id - StudentName
.
How can I do it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…