我想通過會話的幫助按下按鈕時,從網格視圖傳遞一個值到另一個頁面。如何實現它?如何通過會話將值從gridview傳遞到另一個頁面?
C#代碼:
保護無效的Page_Load(對象發件人,EventArgs的)
{
if (!IsPostBack)
{
BindEmployeeDetails();
}
}
protected void BindEmployeeDetails()
{
con.Open();
SqlCommand cmd = new SqlCommand("Select uniqueref,fldCustomerName,fldCustomerAddress,fldCustomerCity,fldOrderValue,fldINRrEUR from asm", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
}
else
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
GridView1.DataSource = ds;
GridView1.DataBind();
int columncount = GridView1.Rows[0].Cells.Count;
GridView1.Rows[0].Cells.Clear();
GridView1.Rows[0].Cells.Add(new TableCell());
GridView1.Rows[0].Cells[0].ColumnSpan = columncount;
GridView1.Rows[0].Cells[0].Text = "No Records Found";
}
}
protected void Add_Click(object sender, EventArgs e)
{
Response.Redirect("add.aspx");
}
protected void Edit_Click(object sender, EventArgs e)
{
Response.Redirect("edit.aspx");
}
你到目前爲止嘗試過什麼嗎?一些代碼示例將會很棒.. –
@SonerGönül在每一行中,第一列是主鍵列,當我按下編輯按鈕時,它將重定向到另一個頁面即編輯頁面。在那裏我編輯相應的列與該編輯頁面中的會話變量中存在的主鍵的幫助。 – ramits
@ramits,你需要證明你已經開始了,問題是可以回答的。 **請顯示您的一些代碼**。 – Liam