Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How Can i convert system.web.ui.webcontrols.table to system.data.datatable .

Plz reply fast .
It's Urgent..

And Thanks in Advance.
Posted
Updated 3-Jun-13 21:10pm
v2
Comments
_Amy 4-Jun-13 3:08am    
It's NOT urgent. Can I see your code?
chirag7749 4-Jun-13 3:10am    
if (gvWeekSalesReport != null)
{
if (gvWeekSalesReport.HeaderRow != null)
{
// table.Rows.Add(dr);
//table.Rows.Add(gvSalesByRegister.HeaderRow);
//GridViewRow gr = new GridViewRow(1,-1, DataControlRowType.DataRow, DataControlRowState.Insert) ;
//gr.Cells[0].Text = ddlStore.SelectedItem.ToString() + " " + calFromDate.SelectedDate.ToShortDateString() + " " + calToDate.SelectedDate.ToShortDateString();
TableRow tr = new TableRow();
TableCell td = new TableCell();
td.Text = ddlStoreGroupList.SelectedItem.ToString() + " - To " + caltodate.SelectedDate.ToShortDateString();
tr.Cells.Add(td);
table.Rows.Add(tr);
}
foreach (GridViewRow row in gvWeekSalesReport.Rows)
{
table.Rows.Add(row);
}

table.Rows.Add(gvWeekSalesReport.HeaderRow);

foreach (GridViewRow row in gvWeekSalesReport.Rows)
{

table.Rows.Add(row);
}
}
_Amy 4-Jun-13 3:15am    
See my solution below.
Instead of TableRow and TableCell use DataRow and DataColumn.

here is the exapmple of table to dataset. you can easily convert it to datatable:
http://forums.asp.net/t/1718918.aspx/1[^]
 
Share this answer
 
There is no direct method for that. You have to loop and add TableRow values to datatable row.


--Amit
 
Share this answer
 
Comments
chirag7749 4-Jun-13 5:51am    
can you solve this???
_Amy 4-Jun-13 5:55am    
This is your homework gentleman. Don't be so depressed. You can do it. Search in google and try it. I am giving the hint.
Loop through the rows of Table, take the values from it and add it in DataTable.
--Amit
chirag7749 5-Jun-13 1:42am    
I try this but row has many column but it take only one column.

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