asp.net - Image upload via gridview question -
I have a Gridwu which database data displays Datbes other things between the image file name for each item (string ).
File upload load control I have shown in the edit view, and it uploads the file properly.
The problem is, I want to update the image filename in the database and I'm not sure that data on how to get in the textbox control, which is used to update Gridviv database. Text Box Control I have hidden visibility. Here is the ASPX code:
& asp: TemplateField HeaderText = "Image" Sorted Expression = "Image" & gt; & Lt; EditItemTemplate & gt; & Lt; Asp: text box id = "txtImage" runat = "server" text = '& lt;% # bind ("image")% & gt; Visible = "false" OnTextChanged = "txtImage_TextChanged" & gt; & Lt; / Asp: Textbox & gt; & Lt; Asp: FileUpload id = "FileUpload1" runat = "server" /> & Lt; / EditItemTemplate & gt; & Lt; ItemTemplate & gt; & Lt; ASP: Image ID = "Image 1" run = "server" width = "50px" optional text & '% l';% # Eval ("image")%> 'ImageUrl =' & lt;% # 'image / hardware / "+ Eval (" Image ")% & gt;' / & Gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt; < / Code> and here is the function that stores the file on the server, and maintains a variable file name:
protected void Gridwu L_roupting ( object sender, Gridwuapdetattargs E) {GridViewRow row = GridView1.Rows [e.RowIndex]; FileUpload fileUpload = row.Cells [0] .FindControl ( "FileUpload1") as FileUpload; if (fileUpload! = null & amp; Fileupload .HasFile) {strFileName = fileUpload.FileName; FileUpload.SaveAs (Server.MapPath ("Image / H Rdveyr / "+ strFileName)); text box txtImage = row.Cells [0] .FindControl (" txtImage ") as the text box; TxtImage.Text = strFileName;}} So where do I go from here? I think the update has already been done or something else? Because "txtImage.Text" does not update the database ... am I out of here or something else? Before that DB can be saved in the right way, can I manipulate the values in the text box in this function? Thanks for your help on this.
If you update the database in the back code, then you should be in Gridview 1_RO Updating. Just able to get the filename, just find the row in the grid in editing mode. Each row in the row collection on the grid contains a rostet property ... you are looking for DataControlRowState.Edit
Comments
Post a Comment