【发布时间】:2015-11-13 09:05:48
【问题描述】:
这是我的 aspx:
<td>
<asp:FileUpload ID="fileupload" runat="server" />
</td>
cs:
这是用来插入的:
SqlCommand com = new SqlCommand("StoredProcedure1", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@Name", Textusername.Text.Trim());
com.Parameters.AddWithValue("@Class", Textclass.Text.Trim());
com.Parameters.AddWithValue("@Section", Textsection.Text.Trim());
com.Parameters.AddWithValue("@Address", Textaddress.Text.Trim());
try
{
string filename = Path.GetFileName(fileupload.PostedFile.FileName);
fileupload.SaveAs(Server.MapPath("~/Images/" + filename));
com.Parameters.AddWithValue("@Image", "Images/" + filename);
com.ExecuteNonQuery();
Response.Redirect("studententry.aspx");
}
catch (Exception ex)
{
btnsub.Text = ex.Message;
}
插入所有细节后,显示为this:
这是从 gridview 编辑的:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
SqlConnection con = Connection.DBconnection();
if (e.CommandName == "EditRow")
{
GridViewRow gr = (GridViewRow)((Button)e.CommandSource).NamingContainer;
int index = gr.RowIndex;
hiddenfield.Value = index.ToString();
Textid.Text = gr.Cells[0].Text;
Textusername.Text = gr.Cells[1].Text;
Textclass.Text = gr.Cells[2].Text;
Textsection.Text = gr.Cells[3].Text;
Textaddress.Text = gr.Cells[4].Text;
}
}
当我从GridView 编辑特定行时,它将编辑预期图像。
所以图像不可编辑。我可以知道如何编辑图像吗?
【问题讨论】: