How To Convert Datable To Html Table?
for my web part,i need to show some data of data table.now,i m developing in asp.net with c#. how i convert to html table from data table?And also,i don't need to show some column such as ItemID.my data table will be like this.
ItemID ItemName Qty Price Unit Amount
I-0001 ItemOne 10 100 Box 1000
I-0002 ItemTwo 20 200 Card 4000 I-0开发者_StackOverflow中文版003 ItemThree 30 300 Tab 9000itemID column is not need to show.i want only itemname,qty,price,unit,amount columns.
please give me right way.regards
chong
aspx file:
<asp:Repeater ID="Items" runat="server">
<HeaderTemplate>
<table>
<tr>
<th>ItemID</th>
<th>ItemName</th>
<th>Qty</th>
<th>Price</th>
<th>Unit</th>
<th>Amount</th>
</tr>
</HeaderTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("ItemID")%></td>
<td><%#Eval("ItemName")%></td>
<td><%#Eval("Qty")%></td>
<td><%#Eval("Price")%></td>
<td><%#Eval("Unit")%></td>
<td><%#Eval("Amount")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
.cs file
Items.DataSource = DateTableID;
Items.DataBind();
There are many ways to do this. If you just want to use the DataGrid
control, here's a pretty comprehensive look at that control.
精彩评论