Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

C#
public void GetItems()
        {
            DataSet ds1 = new DataSet();
            D.id = 2; // select * from ItemTable
            ds1 = C.DATA1(D);
            GridView1.DataSource = ds1.Tables[0];
            GridView1.DataBind();
            GridView2.DataSource = null;
            GridView2.DataBind();

        }
Posted
Updated 16-Nov-16 1:27am
Comments
ZurdoDev 15-Nov-16 11:44am    
The title of your post has nothing to do with the code you have shown nor what you wrote in the body of your question. I have no idea what it is you are asking,

1 solution

Like you said, you want to bind Gridview with the help of Store procedure, please refer
Bind data to ASP.Net GridView using Stored Procedure[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900