0
編輯圖像這裏是我的aspx:如何從GridView的
<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
編輯特定的行,它會修改期望圖像。
所以圖像是不可編輯的。我可以知道如何編輯圖像嗎?