Hi!
I want get result like below in GridView in ASP.Net with static method.
Static method meaning without using database.
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
insertData();
}
}
public void insertData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Category", typeof(string));
dt.Columns.Add("Subcategory", typeof(string));
dt.Rows.Add(1, "Fruits", "Apple");
dt.Rows.Add(2, "Foods", "Oil");
dt.Rows.Add(3, "Vegetables", "Tomato");
Grid.DataSource = dt;
Grid.DataBind();
}
Result I want
Id
|
Category
|
Subcategory
|
1
|
Fruits
|
Apple
|
Banan
|
2
|
Foods
|
Oil
|
Bread
|
3
|
Vegetables
|
Onion
|
Tomato
|