put two field in listbox
-
i want fill listbox with to coulmn of data,first column be id and secend column be name,we fill list box this form: ... ... listbox.datatextfield = "name"; ... ... but this form i have one column in listbox can i do this work ... .. listbox.datatextfield = "id" + "name"; .. .. -- modified at 10:14 Tuesday 28th February, 2006
-
i want fill listbox with to coulmn of data,first column be id and secend column be name,we fill list box this form: ... ... listbox.datatextfield = "name"; ... ... but this form i have one column in listbox can i do this work ... .. listbox.datatextfield = "id" + "name"; .. .. -- modified at 10:14 Tuesday 28th February, 2006
Hai, Its not possible to bind multiple coloums to ListBox. To do so you need to loop through data and do things manually.
Eg:
foreach(DataRow row in tblUser.Rows)
{
ListItem itm = new ListItem(row["id"] + row["name"], row[id);
listbox.Items.Add(itm);
} -
Hai, Its not possible to bind multiple coloums to ListBox. To do so you need to loop through data and do things manually.
Eg:
foreach(DataRow row in tblUser.Rows)
{
ListItem itm = new ListItem(row["id"] + row["name"], row[id);
listbox.Items.Add(itm);
} -
can you say to me how can do this work with c#????? how can write sql cod that concat two field(two columns)
Use + operator for contatenation in C# The code posted by Anish was self Explanatory Even u can use DataSet and Adapter to bind to list Senior Software Engineer
-
Use + operator for contatenation in C# The code posted by Anish was self Explanatory Even u can use DataSet and Adapter to bind to list Senior Software Engineer
-
can you say to me how can do this work with c#????? how can write sql cod that concat two field(two columns)
Hai, String Concatenation is quite simple in C# with the use of
+
operator,eg:
string tmp = row["id"] + " ------" + row["name"];We can also do the code with much more redabilty like,
string tmp = string.Format("{0} ----- {1}", row["id"], row["name"]);
-
i done this work and it is right. but i want to be a distance between them such as a to column for example: id-----------name 1------------aaaa 2------------bbbb 3------------cccccccc 123----------eeeeeeee -- modified at 0:45 Wednesday 1st March, 2006
Just append the ---- in your sql query select name+'-------'+address as Details from persons and we can bind the details column to the dropdownlist. Senior Software Engineer Nothing is Impossible Even Impossible says I'MPOSSSIBLE -- modified at 0:43 Friday 24th March, 2006 "Aim to go where U have never been B4 and Strive to achieve it" http://groups.yahoo.com/subscribe/dotnetforfreshers http://himabinduvejella.blogspot.com