How do I get multiple selection data form a listbox to a dataset t

G

Guest

User selected multiple items in the listbox. How can I put these selected
ids into a dataset table so I can pass it to my crystal report?

Thanks, Alpha
 
G

Guest

Try the following code

DataSet myDs = new DataSet();
DataTable myTable = new DataTable();
DataRow myRow;

myTable.Columns.Add("XXXX");
foreach(ListItem lstItem in lstData.Items)
{
if(lstItem.Selected)
{
myRow = myTable.NewRow();
myRow[0] = lstItem.Text;
myTable.Rows.Add(myRow);
}
}
myDs.Tables.Add(myTable);
Hope this helps
Manoj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top