bbc_sh
یک شنبه 03 شهریور 1387, 22:21 عصر
بوسیله باتنی که توی گرید ویو هست وبا تشخیص commandname میخوام ایدی همون سطر از گریدویو که روی باتن اون کلیک میشه وارد پایگاه داده بشه؟آیدی که وارد پایگاه میشه از نوع string هست.این هم کدش:
int currentrowindex = Int32.Parse(e.CommandArgument.ToString());
string productid = GridView1.DataKeys[currentrowindex].Value.ToString();
if(commandname="bbbbb")
{
SqlCommand cmd = new SqlCommand();
SqlConnection con = new SqlConnection();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_ins_nemoune";
cmd.Parameters.AddWithValue("@product_id", productid);
cmd.Parameters.AddWithValue("@cu_username", Session["user"].ToString());
cmd.Parameters.AddWithValue("@orderdate", DateTime.Now.ToString());
con.Open();
cmd.ExecuteNonQuery();
con.Close();}
http://i34.tinypic.com/1zfhjbb.jpg
int currentrowindex = Int32.Parse(e.CommandArgument.ToString());
string productid = GridView1.DataKeys[currentrowindex].Value.ToString();
if(commandname="bbbbb")
{
SqlCommand cmd = new SqlCommand();
SqlConnection con = new SqlConnection();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_ins_nemoune";
cmd.Parameters.AddWithValue("@product_id", productid);
cmd.Parameters.AddWithValue("@cu_username", Session["user"].ToString());
cmd.Parameters.AddWithValue("@orderdate", DateTime.Now.ToString());
con.Open();
cmd.ExecuteNonQuery();
con.Close();}
http://i34.tinypic.com/1zfhjbb.jpg