B M Suchitra

B M Suchitra

  • NA
  • 507
  • 418k

Load All gridview rows with data from dataset

Nov 30 2011 10:41 PM
Hi,

I have a gridview to which i am adding rows dynamically at the click event of a button placed in gridview footer template. When i want to update data. I have to load the gridview with all the rows required. I get the sql table data in the dataset object and then i have to load this in the gridview. How can i do this?
 Only one row gets loaded when i use this code:

  DataSet DSContact = DMLObj.Load_DataSet("Usp_LoadData", "ContactPerson", idf);

  foreach (GridViewRow row in GVContactPerson.Rows)
  {
 

  ((TextBox)row.FindControl("txtContactName")).Text=DSContact.Tables[0].Rows[0]["ContactName"].ToString();
  ((TextBox)row.FindControl("txtemail")).Text = DSContact.Tables[0].Rows[0]["ContactEmailID"].ToString();
  ((TextBox)row.FindControl("txtmob1")).Text = DSContact.Tables[0].Rows[0]["ContactMobile"].ToString();

  Session["contact"] = ((TextBox)row.FindControl("txtContactName")).Text;
  string pid = Convert.ToString(DMLObj.getid("Select ContactPersonID from tbl_ContactPersonDetails where ContactName='" + Session["contact"].ToString() + "'"));
  Session["contactID"] = pid;

  }

Answers (5)