In Page 1:
protected void btnSend1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
string ItemGroup = ((TextBox)row.FindControl("txtItemGroup")).Text;
string ItemID = ((Label)row.FindControl("lblGroup12")).Text;
if (ItemGroup != null)
{
Update(ItemGroup,ItemID);
}
}
int ID = Convert.ToInt32(txtID.Text);
string url = "Default2.aspx?TestID=" + ID;
string fullURL = "window.open('" + url + "', '_blank');";
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL,true);
}
public void Update(string ItemGroup, string ItemID)
{
int Itemid = Convert.ToInt32(ItemID);
con = new SqlConnection(constr);
sqlstr = "update Test_Items set ItemGroup = '" + ItemGroup + "' where TestItemID = " + Itemid+"";
SqlCommand cmd = new SqlCommand(sqlstr, con);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
}
In Page 2:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ID = Convert.ToInt32(Request.QueryString["TestID"]);
lblTestID.Text = ID.ToString();
}
Foo();
}
public void Foo()
{
sqlstr = "select * from Test_Items where TestID = '"+ID+"'";
SqlDataAdapter da = new SqlDataAdapter(sqlstr, con);
DataTable ds = new DataTable();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}