kaarthikeyan
kaarthikeyan

Reputation: 11

How to bind all the rows of Dataset in gridview

can you please tell me how to bind dataset to gridview

string indno = dsRasisePo.Tables[0].Rows[0]["indno"].ToString();
 for (int i = 0; i < arry.Count; i++)
        {
            string prodid = arry[i].ToString();
            string tid = RaisePurOrder.GetTid(indno, prodid);
            Dataset dsQuotation=RaisePurOrder.Bindquotation(tid);
         }
 gvSelectQuotation.DataSource = dsQuotation;
 gvSelectQuotation.DataBind();

indent no is common only so that i gave like that i want to loop it throug the array count and passing the functions i may get more than one row in dataset now what is the problem is only last row of dataset is bindning in gridview but remaining rows are not yet bind


Upvotes: 1

Views: 4804

Answers (1)

Glory Raj
Glory Raj

Reputation: 17701

Well, This will give an overview how to bind the data with dataset to grid view....

protected void Page_Load(object sender, EventArgs e)
{

   if (!Page.IsPostBack)
   {

          string connectionString = “server=SYS2;” + “integrated security=SSPI;” +  
        “database=ERPFinAccounting”;
     SqlConnection myConnection;
     string str_Account_Select = “SELECT * FROM AccountsTable”;
     SqlCommand myCommand;
     DataSet myDataSet;
     myConnection = new SqlConnection(connectionString);
     myConnection.Open();
     myCommand = new SqlCommand(str_Account_Select, myConnection);
     SqlDataAdapter mySQLDataAdapter;
     myDataSet = new DataSet();
     mySQLDataAdapter = new SqlDataAdapter(myCommand);
     mySQLDataAdapter.Fill(myDataSet, “AccountsTable”);
     GridView1.DataSource = myDataSet;
     GridView1.DataBind();

    }
} 

i hope it will helps you

Upvotes: 3

Related Questions