Click here to Skip to main content
15,918,211 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I found that when I bind rows to a dropdownlist from an Arraylist both the 'value' and 'text' were assigned to the same value.

I don't want this, is there a way to bind the values accordingly?

Please help me,Thank you!!
Posted
Updated 7-Dec-10 21:44pm
v2
Comments
mylogics 8-Dec-10 1:54am    
what exactly u want.you want to assign different values to text and value field.post your code.
Dalek Dave 8-Dec-10 3:44am    
Edited for Readability.

hope it works.....
dropdownlist1.datavaluefield.text
dopdownlist1.datatextfield.text
 
Share this answer
 
Comments
Wanlambok 8-Dec-10 1:51am    
But how can i bind it from an arraylist???
Fill the the data's in DataTable. Then assisgn this DataTable to the DropDownList.
ddl.DataSource = dataTable
ddl.DataValueField = "value field name"
ddl.DataTextField = "textfield name"
dd.DataBind()
 
Share this answer
 
OleDbConnection con = new OleDbConnection(connection);
                DataSet ds = new DataSet();
                OleDbDataAdapter ad = new OleDbDataAdapter("select Tittle from smsstorage order by Tittle Asc", con);
                ad.Fill(ds);
                //ddlsmsstorage.Items.Clear();
                ddlsmsstorage.Items.Add("---Select---");


                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ddlsmsstorage.Items.Add(ds.Tables[0].Rows[i][0].ToString());

               
                   
                }

like this also we can add which field you want.............
 
Share this answer
 
v2
Comments
Dalek Dave 8-Dec-10 3:45am    
Edited for Code Block, but good 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