year = GridView1.Rows[i].Cells[5].Text;

i have written above code for getting value of particular cell from gridview. but now i want to store variable value in particular cell of gridview.

then you need something like this

GridView1.Rows[i].Cells[5].Text = year;

your i will be your row index

i tried this but this gives error as arument out of range.

Yes , you must use the Correct index , the "i" and the cell must be match the grid

DataRow dr = ds.Tables["guest"].NewRow();    //create new row in dataset
            dr[0] = variable;               //store value 
            dr[1] = TextBox2.Text;
            -
            -
            ds.Tables[0].Rows.Add(dr);              //now add that row to dataset 
            GridView1.DataSource = ds.Tables[0];   //bind the gridview 
            GridView.DataBind();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.