更新gridveiw的问题 [英] Problem with updating gridveiw

查看:76
本文介绍了更新gridveiw的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们

我创建了一个包含照片和标题的Gridview。我还创建了一个链接按钮来编辑照片和标题。此链接按钮将用户转移到第二页以编辑gridview的标题和照片。在新页面中使用编程更改照片但标题不会更改。

程序是:

  protected   void  Button1_Click(object sender,EventArgs e)
{

int id = Convert.ToInt32(Request.QueryString [ Code]);

string filename = FileUpload1.ToolTip;
if (FileUpload1.HasFile)
{
filename = FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath( pics \\)+ filename );
}

SqlConnection con = new SqlConnection();
con.ConnectionString = 数据源= .;初始目录= tbldms1;集成安全性=真;
string q = update ooo set title = @ title,photo = @ photo,其中id = @ id ;
SqlCommand cmd = new SqlCommand(q,con);
cmd.Parameters.AddWithValue( @ id,id);
cmd.Parameters.AddWithValue( @ title,TextBox1.Text);
cmd.Parameters.AddWithValue( @ photo,filename);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
TextBox1.Text = ;

}



请帮帮我

祝福

解决方案

陡峭1:在此查询中

  string  q =   update ooo set title = @ title,photo = @ photo,其中id = @ id; 



删除昏迷



  string  q =   update ooo set title = @ title,photo = @ photo where id = @ id; 





步骤2:检查文本框中的值是什么

 TextBox1.Text 


Dear my friends
I created a Gridview which was contained photo and title. I also created a linkbutton to edit the photo and title. this linkbuttton transfer the users to the second page to edit the title and photo of gridview. in new page using of programming the photo is changed but the title is not changed.
the program is :

protected void Button1_Click(object sender, EventArgs e)
       {

           int id = Convert.ToInt32(Request.QueryString["Code"]);

           string filename = FileUpload1.ToolTip;
           if (FileUpload1.HasFile)
           {
               filename = FileUpload1.FileName;
               FileUpload1.SaveAs(Server.MapPath("pics\\") + filename);
           }

           SqlConnection con = new SqlConnection();
           con.ConnectionString = "Data Source=.;Initial Catalog=tbldms1;Integrated Security=True";
           string q = "update ooo set title=@title,photo=@photo,where id=@id";
           SqlCommand cmd = new SqlCommand(q, con);
           cmd.Parameters.AddWithValue("@id", id);
           cmd.Parameters.AddWithValue("@title", TextBox1.Text);
           cmd.Parameters.AddWithValue("@photo",filename);
           con.Open();
           cmd.ExecuteNonQuery();
           con.Close();
           TextBox1.Text = "";

       }


please help me
Best wishes

解决方案

Steep 1 : In this query

string q = "update ooo set title=@title,photo=@photo,where id=@id";


remove the coma

string q = "update ooo set title=@title,photo=@photo where id=@id";



Step 2: Check what is the value in text box

TextBox1.Text


这篇关于更新gridveiw的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆