Click here to Skip to main content
15,895,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,

i want to bind a multiple item in datagrid. here is my code :-

C#
protected void GrdOrder_EditCommand(object source, DataGridCommandEventArgs e)
    {
        int OID = Convert.ToInt32(GrdOrder.DataKeys[e.Item.ItemIndex]);
        DatabaseHelper db = new DatabaseHelper();
        DataSet ds = db.GetOrderByID(OID);

        if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
        {
            hndID.Value = OID.ToString();

            lblorderno.Text = ds.Tables[0].Rows[0]["OrderID"].ToString();
            lblodate.Text = ds.Tables[0].Rows[0]["OrderDate"].ToString();
            lblstore.Text = ds.Tables[0].Rows[0]["StoreName"].ToString();
            lblcheck.Text = ds.Tables[0].Rows[0]["CheckoutType"].ToString();
            lbladdress.Text = ds.Tables[0].Rows[0]["ShippingAddress"].ToString();
            lblzone.Text = ds.Tables[0].Rows[0]["ZoneName"].ToString();
            lblstate.Text = ds.Tables[0].Rows[0]["StateName"].ToString();
            lblcity.Text = ds.Tables[0].Rows[0]["CityName"].ToString();
            lblpincode.Text = ds.Tables[0].Rows[0]["PinCode"].ToString();
            lblcontact.Text = ds.Tables[0].Rows[0]["ContactNo"].ToString();
            lblemail.Text = ds.Tables[0].Rows[0]["EmailID"].ToString();
            ltrOrderAmount.Text = ds.Tables[0].Rows[0]["NetAmount"].ToString();
         
        }

        db.GetProductByOrderID(Convert.ToInt32(lblorderno.Text));
        if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
        {
            for (int i = 1; i < ds.Tables[0].Rows.Count; i++)
            {

            }
        }
}


now i want to bind all the product in another gridview or datagrid. how can i bind using for loop or foreach loop..


Thank You...!!!
Posted
Comments
Career Web Helper 22-Aug-12 3:22am    
way of using for loop and foreach loop is same bt only matters is performance thas it

Bind the second grid using the dataset ds. You need not use a for loop
 
Share this answer
 
C#
db.GetProductByOrderID(Convert.ToInt32(lblorderno.Text));
        if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
        {
            for (int i = 1; i < ds.Tables[0].Rows.Count; i++)
            {
                GrdProduct.DataSource = ds.Tables[0];
                GrdProduct.DataBind();
            }
        }



I directly bind gridview.
Thank You......
 
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