dark_cyber
New Member
I have 2 pages, page 1 include the \[code\]gridview\[/code\] and I made one \[code\]linkbutton\[/code\] that passes the ID to another page ( page 2). On page 2 I fill 10 \[code\]textbox\[/code\]es and I have one button for edit info.This code is for page 1 : \[code\]... <asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="lbNextPage" runat="server" PostBackUrl='<%# "~/secure/upst.aspx?id="+ Eval("ID_st") %>'>edit</asp:LinkButton> </ItemTemplate> </asp:TemplateField>\[/code\]...and this is the code for page 2: \[code\]protected void Page_Load(object sender, EventArgs e){ if (!IsPostBack) { txtID.Text = Request.QueryString["id"].ToString(); } SqlConnection con = new SqlConnection(strcon); string query = "select * from user_st where ID_st = @id"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@id", stid); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); txtName.Text = dr["name"].ToString(); txtFamily.Text = dr["family"].ToString(); txtAddress.Text = dr["adres"].ToString(); txtHomeTel.Text = dr["home_tel"].ToString(); txtTahsilat.Text = dr["tahsilat"].ToString(); txtTel.Text = dr["celphone"].ToString(); txtEmail.Text = dr["email"].ToString(); txtShoghl.Text = dr["shoghl"].ToString(); txtAge.Text = dr["age"].ToString(); txtFadername.Text = dr["fader_name"].ToString(); txtIDnumber.Text = dr["melli_code"].ToString(); txtShSh.Text = dr["sh_sh"].ToString();} protected void btnOk_Click(object sender, EventArgs e){ Boolean res = false; SqlConnection conn = new SqlConnection(strcon); string famil = txtFamily.Text; string name = txtName.Text; string fader = txtFadername.Text; string tahsil = txtTahsilat.Text; Double telhome = Convert.ToDouble(txtHomeTel.Text); string adres = txtAddress.Text; Double cel = Convert.ToDouble(txtTel.Text); string email = txtEmail.Text; Double shsh = Convert.ToDouble(txtIDnumber.Text); string shoghl = txtShoghl.Text; int age = Convert.ToInt32(txtAge.Text); Double melli = Convert.ToDouble(txtIDnumber.Text); int id = Convert.ToInt32(txtID.Text); string query = "update user_st set name=@name ,fader_name=@fader ,family=@famil,tahsilat=@tahsil,adres=@adres,home_tel=@telhome,celphone=@cel,email=@email ,sh_sh=@shsh,shoghl=@shoghl,age=@age,melli_code=@melli where ID_st=@id"; SqlCommand cmdup = new SqlCommand(query, conn); cmdup.Parameters.AddWithValue("@name",name); cmdup.Parameters.AddWithValue("@fader_name",fader ); cmdup.Parameters.AddWithValue("@family", famil); cmdup.Parameters.AddWithValue("@tahsilat",tahsil); cmdup.Parameters.AddWithValue("@adres", adres); cmdup.Parameters.AddWithValue("home_tel",telhome ); cmdup.Parameters.AddWithValue("@celphone",cel ); cmdup.Parameters.AddWithValue("@email", email); cmdup.Parameters.AddWithValue("@sh_sh", shsh); cmdup.Parameters.AddWithValue("@shoghl", shoghl); cmdup.Parameters.AddWithValue("@age",age ); cmdup.Parameters.AddWithValue("@melli_code", melli); cmdup.Parameters.AddWithValue("@id", id); try { conn.Open(); cmdup.ExecuteNonQuery(); conn.Close(); res = true; } catch (SqlException ex) { lblRes.Text = "error" + ex.ToString(); } if (res) { lblResult.Text = "Ok"; }\[/code\]That is not working so, I tried this:\[code\] //cmdup.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = http://stackoverflow.com/questions/12664864/txtName.Text; //cmdup.Parameters.Add("@fader_name", SqlDbType.NVarChar, 50).Value = http://stackoverflow.com/questions/12664864/txtFadername.Text; //cmdup.Parameters.Add("@family", SqlDbType.NVarChar, 50).Value = http://stackoverflow.com/questions/12664864/txtFamily.Text; //cmdup.Parameters.Add("@tahsilat", SqlDbType.NVarChar, 50).Value = http://stackoverflow.com/questions/12664864/txtTahsilat.Text; //cmdup.Parameters.Add("@adres", SqlDbType.NVarChar, 150).Value = http://stackoverflow.com/questions/12664864/txtAddress.Text; //cmdup.Parameters.Add("home_tel", SqlDbType.Char, 10).Value = http://stackoverflow.com/questions/12664864/txtHomeTel.Text; //cmdup.Parameters.Add("@celphone", SqlDbType.Char, 10).Value = http://stackoverflow.com/questions/12664864/txtTel.Text; //cmdup.Parameters.Add("@email", SqlDbType.VarChar).Value = http://stackoverflow.com/questions/12664864/txtEmail.Text; //cmdup.Parameters.Add("@sh_sh", SqlDbType.Char, 10).Value = http://stackoverflow.com/questions/12664864/txtShSh.Text; //cmdup.Parameters.Add("@shoghl", SqlDbType.NVarChar, 50).Value = http://stackoverflow.com/questions/12664864/txtShoghl.Text; //cmdup.Parameters.Add("@age", SqlDbType.Int).Value = http://stackoverflow.com/questions/12664864/txtAge.Text; //cmdup.Parameters.Add("@melli_code", SqlDbType.Char, 10).Value = http://stackoverflow.com/questions/12664864/txtIDnumber.Text; //cmdup.Parameters.Add("@id", SqlDbType.Int).Value = http://stackoverflow.com/questions/12664864/txtID.Text;\[/code\]or this : \[code\] //SqlCommand cmdup = new SqlCommand("EXEC up_st'" + txtName.Text. + "' , '" + txtFamily.Text + "' , '" + txtTahsilat.Text +"' , '" + txtAddress.Text + "' , '" // + txtHomeTel.Text + "' , '" + txtTel.Text + "' , '" + txtEmail.Text + "' , '" + txtShoghl.Text + "' , '" // + txtAge.Text + "' , '" + txtFadername.Text + "' , '" + txtIDnumber.Text + "' , '" + txtShSh.Text + "' , '" // + txtID.Text + "'", conn);\[/code\]or this : \[code\] /*"update user_st set name='" + txtName.Text + "',fader_name='" + txtFadername.Text + "',family='" + txtFamily.Text + "',tahsilat='" + txtTahsilat.Text + "',adres='" + txtAddress.Text + "',home_tel='" + txtHomeTel.Text + "',celphone='" + txtTel.Text + "',email='" + txtEmail.Text + "',sh_sh='" + txtShSh.Text + "',shoghl='" + txtShoghl.Text + "',age='" + txtAge.Text + "',melli_code='" + txtIDnumber.Text + "' where ID_st=" + txtID.Text*/\[/code\]but it also doesn't work.