TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shashi kiran Jillepally
NA
56
6.8k
How to show two values(columns) in dropdownlist
Feb 28 2014 2:06 AM
I have a asp:dropdownlist I'm binding two values(columns from sql table) to it 1.EmpId and 2.EmpName 1 as DataText field and 2 as DataValueField its fine but my requirement is i want display both 1 and 2 in the dropdownlist
E-001 shashi
E-002 Abhijit
E-003 Laxmanan
when select EmpId should be selecteditem and EmpName should Selectedvalue
i have written the my code like this but i am getting problem with selecteditem due to concating..
public void BindEmp()
{
Ds = ObjTrip.BlOnLoadTrip();
DataTable Dt = new DataTable();
string Eid = string.Empty;
string EmpName = string.Empty;
string EIdEname = string.Empty;
Dt = Ds.Tables[2];
foreach (DataRow dtr in Dt.Rows)
{
Eid = dtr["EmpCode"].ToString();
EmpName = dtr["Driver"].ToString();
EIdEname = Eid + "------------" + EmpName;
ddlDriverName.Items.Add(new ListItem(EIdEname, Eid));
}
}
Result
selecteditem: E-002------------Abhijit
Selectedvalue:E-002
Reply
Answers (
6
)
how to use session state
what is the use of callback in asp.net?