Reputation: 21
I have a asp table and working dataset.How can I bind the dataset with the table.The code is here....
<asp:table id="tblcampaign" runat="server" width="100%" border="0" cellspacing="0" cellpadding="0">
<asp:TableHeaderRow ID="content_table_heading">
<asp:TableHeaderCell Width="39"><img src="Images/table_heading_bg_lft.gif" alt="" width="39" height="41" /></asp:TableHeaderCell>
<asp:TableCell width="91">Campaign ID</asp:TableCell>
<asp:TableCell width="132">Campaign Name</asp:TableCell>
<asp:TableCell width="134">Parent Campaign</asp:TableCell>
<asp:TableCell width="121">Target Segment</asp:TableCell>
<asp:TableCell width="95">Objective</asp:TableCell>
<asp:TableCell width="130">Planned Start Date</asp:TableCell>
<asp:TableCell width="134">Planned End Date</asp:TableCell>
<asp:TableCell width="52">Status</asp:TableCell>
<asp:TableCell width="39"><img src="Images/table_heading_bg_rt.gif" alt="" width="39" height="41" /></asp:TableCell>
</asp:TableHeaderRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="10"><img src="Images/spacer.gif" alt="" width="1" height="8" /></asp:TableCell>
</asp:TableRow>
<asp:TableRow CssClass="tr_style1">
<asp:TableCell> </asp:TableCell>
<asp:TableCell CssClass="table_text_style2">01</asp:TableCell>
<asp:TableCell ><a href="#">abc entertainment</a></asp:TableCell>
<asp:TableCell >None</asp:TableCell>
<asp:TableCell >Segment 1</asp:TableCell>
<asp:TableCell >Objective 1</asp:TableCell>
<asp:TableCell CssClass="table_text_style2">01/01/2010</asp:TableCell>
<asp:TableCell CssClass="table_text_style2">01/01/2010</asp:TableCell>
<asp:TableCell >Planned</asp:TableCell>
<asp:TableCell> </asp:TableCell>
</asp:TableRow>
.cs code is here..
MCMS.DAL.Dataset.MobileCampaign mob_cam = new MCMS.DAL.Dataset.MobileCampaign();
MCMS.BL.MobileCampaignHandler obj = new MCMS.BL.MobileCampaignHandler();
mob_cam = obj.GetCampaignDetails();
Upvotes: 0
Views: 7003
Reputation: 12589
Is there a reason why you're not using a Gridview for this?
What you need to do is for every row in your DataSet, create a new TableRow, create the cells, and add it to the table, something like:
//Build a row for each record in the DataSet
foreach (DataRow myDataRow in MyDataSet.Tables[0].Rows)
{
TableRow myTableRow = new TableRow();
//Add a cell for each column in the DataSet
for (int i = 0; i < myDataRow.ItemArray.GetUpperBound(0); i++)
{
TableCell myTableCell = new TableCell();
myTableCell.Text = myDataRow[i].ToString();
myTableRow.Cells.Add(myTableCell);
}
//Add the row to the table
tblcampaign.Rows.Add(myTableRow);
}
But a Gridview's much easier...
Upvotes: 2