I have an ImageURL type field in my database. In my List I want to display that image & let the user browse image while editing & inserting. Image path saved in DB is : ~/CRMImages/Projects/vincitoreGardens/buildingLogo.png
In ItemTemplate, when I bind the property to Image, it gives error :
Instead of binding, if I physically provide the same path to ImageUrl, then it works perfectly well :
In my EditItemTemplate, I have added a FileUpload control :
I am not able to access unitPlanImgUpload control in UpdateMethod of the ListView.
public void unitPlanList_UpdateItem(int UnitPlanTypeId)
{
FileUpload img = unitPlanList.FindControl("unitPlanImgUpload") as FileUpload; // REturns NULL
if (img != null) {
if (img.HasFile)
{
System.Diagnostics.Debug.WriteLine("EDIT UNIT PLAN FILE NAME =" + img.FileName);
}
}
I believe, ItemBound event is to bind the data to something before editing/inserting. Here I want to access the control before updating and assign the filename to the property and save it on the server. I tried using unitPlanList.EditItemTemplate to find the control in EditItemtemplate, but unfortunately it doesn't have any Find method.
Any idea what to do and how to access the file selected ??
Any help is highly appreciated.
Thanks
Khargesh RajputPosted Mar 24, 2015, 11:54 PM
http://forums.asp.net/t/1532233.aspx?Formview+Insert+Item+Template+fill+like+Edit+Item+Template+for+all+fields
http://www.learn-asp.net/asptutorials/formview.aspx
TerryPosted Mar 24, 2015, 9:55 AM
Wow Eval works. Surprised, how come Bind gives error & the same Eval works.
Great. Thanks a lot for that.
Can you give suggestion for EditItem & InsertItem for FileUpload stuff asked in Question !!
Khargesh RajputPosted Mar 24, 2015, 6:12 AM