I have a grid view.
I want to take the selected row from the grid view and pass on a column value in that row to a new page while storing that value in the session.
So far I know how to store it as a string from a tut, but don’t know how to keep the value in int format not convert it to string.
Here is what I have in my C# code…Like I said this does write out the row as a string type I want it to remain a int.
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
Int16 num = Convert.ToInt16(e.CommandArgument);
TextBox2.Text = GridView1.Rows[num].Cells[0].Text;
}
}
Putting it into session will be easy. I figured out it is:
Session["customerID"] = GridView1.Rows[num].Cells[0].Text;
So now the true question is how to keep the value in a int format.
Thanks!
You can not save it in int type directly.Session stores the value in object type. So you have to cast it as int.