TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Terry
NA
148
0
Access a Control from EditItemTemplate and update a Property
Mar 23 2015 5:09 PM
Hi,
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 :
<!-- <asp:Image runat="server" ImageUrl='<%# Bind("UnitPlanImageUrl") %>' Width="30" Height="30" /> -->
Instead of binding, if I physically provide the same path to ImageUrl, then it works perfectly well :
<asp:Image runat="server" ImageUrl="~/CRMImages/Projects/vincitoreGardens/buildingLogo.png" Width="30" Height="30" />
In my EditItemTemplate, I have added a FileUpload control :
<td>
<asp:FileUpload runat="server" ID="unitPlanImgUpload" />
</td>
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
Reply
Answers (
3
)
Hide ListView on Button Click
Find the sum of all values of a column in ListView