Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
XML
<asp:DropDownList ID="ddlbookname"  
                                        runat="server" AutoPostBack="true">
                                    </asp:DropDownList>




and my code behind code is as shown below

DataTable dtbookname = new DataTable();
objRetailPL.status = 1;
dtbookname = objRetailBAL.GetTypeNew(objRetailPL);
if (dtbookname.Rows.Count > 0)
{
ddlbookname.DataSource = dtbookname;
ddlbookname.DataTextField = "BookName";
ddlbookname.DataValueField = "sno";
ddlbookname.DataBind();
ddlbookname.Items.Add(new ListItem("--Select--", "0"));
ddlbookname.SelectedIndex = ddlbookname.Items.Count - 1;
}


out put is

xxxx

yyyy

aaaa

bbbb

cccc

dddd

eeee

ffff

....

....

.....

.....

.....

zzzzz

like this but actually I want is

xxxx yyyyy aaaa bbbb ccccc

dddd eeeee ffff gggg hhhh

.... ..... .... .... .....

.... ..... .... .... .....

like this

I have this dropdownlist, and this is having more data so I want to show it in multi column in dropdownlist how can I please help me....
Posted
Comments
Karthik_Mahalingam 4-Feb-14 4:06am    
if you put multicolumn then how will you get the sno ??
santhu888 4-Feb-14 4:12am    
ddlbookname.DataValueField = "sno"; with this i am getting sno na ....is it possible or not?
Karthik_Mahalingam 4-Feb-14 4:33am    
xxxx yyyyy aaaa bbbb ccccc these all are BookName ??
not possible..
santhu888 4-Feb-14 4:44am    
k leave about sno....
if I want to show only booknames in multi columns tell me how?
Karthik_Mahalingam 4-Feb-14 4:51am    
then how will you select single book form drop down list ?

1 solution

Either concatenate the different columns into single item in Dropdownlist and display like below

Display Multiple Columns in DDL[^]

Or you need to create a CustomControl to Implement it in a much cleaner way as below

Multiple Columns DropDown for ASP.NET[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900