ajaxuploader inside listview

Last post 04-26-2010, 10:04 PM by cutechat. 1 replies.
Sort Posts: Previous Next
  •  04-26-2010, 2:18 AM 60393

    ajaxuploader inside listview

    I put ajaxuploader inside <UpdateItemTemplate> of ListView. Except uploader there's a TextBox1 and I want to update its Text property with the address of uploaded image. So I've got the problem with assigning data to TextBox1.Text.
    I tried to assign image_address.Text property through Label4.Text which is outside of listview, but it doesn't work.
    How to find TextBox1 control? Or how to update property correctly?
    1. public void Uploader_FileUploaded(object sender, UploaderEventArgs args)  
    2. {  
    3.         args.CopyTo(@"D:\images\menu\" + args.FileName);  
    4.         ResizeImage(@"D:\images\menu\" + args.FileName, @"D:\images\menu\small_" + args.FileName, 150, 100, false);  
    5.         args.Delete();  
    6.         Label4.Visible = true;  
    7.         Label4.Text = @"D:\imagesmenu\small_" + args.FileName;  
    8.         //(TextBox) huyimg = (TextBox)(ListView1.Controls[0].FindControl("TextBox1"));  
    9.         TextBox huyimg = (TextBox)(ListView1.Items[ListView1.SelectedIndex].FindControl("TextBox1"));  
    10.         huyimg.Text = @"D:\imagesmenu\small_" + args.FileName;  
    11. }  
    12.   
    13. protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)  
    14.     {   
    15.         ListViewItem myItem = ListView1.Items[ListView1.EditIndex]; 

    16.         TextBox image_address = (TextBox)(ListView1.Items[e.ItemIndex].FindControl("TextBox1"));  
    17.         image_address.Text = Label4.Text;  
    18.   
    19.         ...
    20.   
    21.         ListView1.EditIndex = -1;  
    22.         BindList();  
    23.     }
  •  04-26-2010, 10:04 PM 60427 in reply to 60393

    Re: ajaxuploader inside listview

    Hi,
     
    You can do that by 2 ways :
     
    1 - in FileUploaded event , you can use Uploader uploader=(Uploader)sender; use uploader.Parent to get the ListViewItem and then find the textbox.
     
    2 - you can use UploadPersistedFile/UploadAttachments to hold the uploaded file, and in the ItemUpdating event, use uploader.File/Items to get the uploaded files , do not need FileUploaded event.
     
    Regards,
    Terry
     
View as RSS news feed in XML