I got the following code create two GriViews and first GridView is used to show the details and the second one is used to display the rows when clicking CheckBoxes.
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[5] { new DataColumn("itemcode", typeof(int)),
new DataColumn("itemname", typeof(string)),
new DataColumn("unit", typeof(string)),
new DataColumn("price", typeof(string)),
new DataColumn("stock_qty",typeof(string)) });
dt.Rows.Add(1, "Android Phone", "Nos", "30000", "50");
dt.Rows.Add(2, "Iphone", "Nos", "50000", "20");
dt.Rows.Add(3, "Samsung pohne", "Nos", "40000", "15");
GridView1.DataSource = dt;
GridView1.DataBind();
GridView2.DataSource = null;
GridView2.DataBind();
}
}
What I have tried:
But, i would like modify the code to get the data from SQL database.Hence, i want to modify above code with following codes to get data from Database using Stored procedure id as follows:
public void GetItems()
{
DataSet ds1 = new DataSet();
D.id = 2;
ds1 = C.DATA1(D);
GridView1.DataSource = ds1.Tables[0];
GridView1.DataBind();
GridView2.DataSource = null;
GridView2.DataBind();
}