Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to bind listbox items to gridview ....Actually i have URL in that listbox... so
how that listbox items activate link buttons in gridview?
Posted
Comments
Richard MacCutchan 25-Jan-13 8:05am    
You only posted this an hour ago; learn some patience. People will answer in their own time and at no cost to you.
Deenuji 25-Jan-13 8:23am    
k k sorry sir....

1 solution

Hi,
You may try this,
C#
GridView1.DataSource = ListBox1.DataSource
;

or use this,

C#
GridView1.DataSource = getDataSource(ListBox1.Items);

 private DataTable getDataSource(ListItemCollection listItemCollection)
        {
            DataTable dtTemp = new DataTable();
            dtTemp.Columns.Add("MyItems");
            foreach (ListItem item in listItemCollection)
            {
                DataRow drTemp = dtTemp.NewRow();
                drTemp["MyItems"] = item.Text;
                dtTemp.Rows.Add(drTemp);
            }
            return dtTemp;
        }
 
Share this answer
 
v2

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