You can use
Gridview to display the data from datatable in aspx page.
Sample Code:
<asp:GridView ID="GridView4" runat="server" AutoGenerateColums="false">
<Columns>
<%--Add your columns here--%>
</Columns>
</asp:GridView>
You can use Datasource to assign the datatable to Gridview
//Loading dummy data
DataTable table = new DataTable();
table.Columns.Add("Column1", typeof(string));
table.Columns.Add("Column2", typeof(string));
table.Columns.Add("Column3", typeof(string));
table.Columns.Add("Column4", typeof(string));
// Here we add five DataRows.
table.Rows.Add("Sample1", "Sample2", "", "Sample4");
table.Rows.Add("TestValue1", "TestValue2", "TestValue3", "TestValue3");
//Assigning datasoure to gridview
GridView4.DataSource=table;
GridView4.DataBind();
Also if you want to display a particular value then use a label control or textbox control
<asp:Label ID="Label2" runat="server" Text=""></asp:Label> C#:
//Loading dummy data
DataTable table = new DataTable();
table.Columns.Add("Column1", typeof(string));
table.Columns.Add("Column2", typeof(string));
table.Columns.Add("Column3", typeof(string));
table.Columns.Add("Column4", typeof(string));
// Here we add five DataRows.
table.Rows.Add("Sample1", "Sample2", "", "Sample4");
table.Rows.Add("TestValue1", "TestValue2", "TestValue3", "TestValue3");
Label2.Text=table.Rows[0]["Column1"].ToString();
Thanks,
A2H
My Blog
Amatya, if this helps please login to Mark As Answer. | Alert Moderator