本文介绍了更新后,gridview图像列在asp.net中变为空c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我有一个网格视图,单击更新按钮后,图像列变为空.
我在图像存储过程中的数据类型是图像.
谁能帮我这个忙.
我的CS文件代码
Hello
I have a grid view, after clicking an update button the image column is going null.
My data type in stored procedure for image is image.
Can any one help me with this.
My code for cs file
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//june25
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
Label lblID = (Label)row.FindControl("lblID");
//Image Image = (Image)row.FindControl("Image1");
TextBox textName = (TextBox)row.FindControl("txtName");
TextBox textDesc = (TextBox)row.FindControl("txtDesc");
TextBox textImage = (TextBox)row.FindControl("txtImage");
TextBox textActive = (TextBox)row.FindControl("txtActive");
TextBox textCreatedBy = (TextBox)row.FindControl("txtCreatedBy");
TextBox textCreatedDate = (TextBox)row.FindControl("txtCreatedDate");
FileUpload FileUpload2 = (FileUpload)row.FindControl("FileUpload2");
//FileUpload FileUpload2 = (FileUpload)GridView1.Rows[e.RowIndex].FindControl("FileUpload2");
GridView1.EditIndex = -1;
conn.Open();
//SqlCommand cmd = new SqlCommand("UPDATE tbl_SqlImage set Name='" + textName.Text + "' , Description='" + textDesc.Text + "' , Image='" + textImage.Text + "' , Active='" + textActive.Text + "' , CreatedBy='" + textCreatedBy.Text + "' , CreatedDate='" + textCreatedDate.Text + "' where ID='" + lblID.Text.Trim() + "' ", conn);
SqlCommand cmd = new SqlCommand("UPDATE tbl_SqlImage set Name='" + textName.Text + "' , Description='" + textDesc.Text + "' , Image='" + textImage.Text + "' , Active='" + textActive.Text + "' , CreatedBy='" + textCreatedBy.Text + "' , CreatedDate='" + textCreatedDate.Text + "' where ID='" + lblID.Text.Trim() + "' ", conn);
cmd.ExecuteNonQuery();
conn.Close();
bind();
GridView1.DataBind();
//june25
推荐答案
这篇关于更新后,gridview图像列在asp.net中变为空c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!