Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have one listbox.im binding the listbox using below given code.
C#
DataSet dataSetEntity = new DataSet();
        dataSetEntity = CDL.dataset(strSql);
        if (dataSetEntity.Tables[0].Rows.Count > 0)
        {
            lstBox.DataSource = dataSetEntity.Tables[0].DefaultView;
            lstBox.DataTextField = "Entity_Name";
            lstBox.DataValueField = "Entity_ID";
            lstBox.DataBind();           
        }

The values are coming properly in dataset.but values are not coming in listbox.please help me
Posted
Updated 17-Jul-13 1:33am
v2

1 solution

Try this way.

C#
DataSet dataSetEntity = new DataSet();
dataSetEntity = CDL.dataset(strSql);

if (dataSetEntity.Tables[0].Rows.Count > 0)
{
 lstBox.DisplayMember = "Entity_Name";
 lstBox.ValueMember = "Entity_ID";
 lstBox.DataSource = dataSetEntity.Tables[0];
 //lstBox.DataBind();

}
 
Share this answer
 
Comments
sony76 17-Jul-13 7:52am    
now values are coming in listbox,but when page load the values are disappearing from listbox.
Umapathi K 17-Jul-13 8:02am    
use separate function for that and place the function in page_load
sony76 17-Jul-13 8:11am    
ya.like that only im doing

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