Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. GridView inside UpdatePanel not Uploading Image

GridView inside UpdatePanel not Uploading Image

Scheduled Pinned Locked Moved ASP.NET
databasehelpquestionannouncement
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NET India
    wrote on last edited by
    #1

    Hello Friends, I've a GridView inside a UpdatePanel. And there is a Fileupload control inside the GridView which is fired to Update the existing image with newer one. My code is running perfectly without UpdatePanel. But as i put my GridView inside the UpdatePanel it gives me an error "Object References not set to an instance". I think this error is being generated because of FileUpload control. So i want to have a trigger control of UpdatePanel to upload the new image. How can i bind a trigger control of UpdatePanel at RowUpdating event of GridView at code behind

    A 1 Reply Last reply
    0
    • N NET India

      Hello Friends, I've a GridView inside a UpdatePanel. And there is a Fileupload control inside the GridView which is fired to Update the existing image with newer one. My code is running perfectly without UpdatePanel. But as i put my GridView inside the UpdatePanel it gives me an error "Object References not set to an instance". I think this error is being generated because of FileUpload control. So i want to have a trigger control of UpdatePanel to upload the new image. How can i bind a trigger control of UpdatePanel at RowUpdating event of GridView at code behind

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      If you have to refresh the grid when file upload occurs why do you place the GridView inside the update panel??? :confused: You can use PostBack trigger to upload files.. :) :) Check this[^] how they are doing fileupload from within the updatepanel using PostBack Trigger. :rose:

      Abhishek Sur


      My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

      **Don't forget to click "Good Answer" if you like to.

      N 1 Reply Last reply
      0
      • A Abhishek Sur

        If you have to refresh the grid when file upload occurs why do you place the GridView inside the update panel??? :confused: You can use PostBack trigger to upload files.. :) :) Check this[^] how they are doing fileupload from within the updatepanel using PostBack Trigger. :rose:

        Abhishek Sur


        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

        **Don't forget to click "Good Answer" if you like to.

        N Offline
        N Offline
        NET India
        wrote on last edited by
        #3

        I dont have to refresh the page. I just want to use PostBack trigger. But PostBack trigger needs a ControlID so what will be the ControlID for PostBack Trigger. Because i'm using RowUpdating event of GridView......

        A 1 Reply Last reply
        0
        • N NET India

          I dont have to refresh the page. I just want to use PostBack trigger. But PostBack trigger needs a ControlID so what will be the ControlID for PostBack Trigger. Because i'm using RowUpdating event of GridView......

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          AFAIK... Postback trigger will used to postback the whole page to the server... The controlId of the PostBack trigger should be the control that should invoke the Postback from within the UpdatePanel. If you want Button1 which is placed within the UpdatePanel to postback the page, rather than going for partial update, just use ControlID = "Button1" For your help, lets give you a sample code :

          <asp:UpdatePanel ID="upTest" ChildrenAsTriggers="False" UpdateMode="Conditional" runat="server">
          <ContentTemplate>
          <asp:Label ID="lblResults" runat="server"></asp:Label><br /><br />
          <asp:Button ID="btnAsync" Text="Asynch Post" runat="server" OnClick="btnAsync_Click" />
          <asp:Button ID="btnFullPost" Text="Full Post" runat="server" OnClick="btnFullPost_Click" >
          </ContentTemplate>
          <Triggers>
          <asp:AsyncPostBackTrigger ControlID="btnAsync" EventName="Click" />
          <asp:PostBackTrigger ControlID="btnFullPost" />
          </Triggers>
          </asp:UpdatePanel>

          AsyncPostBackTrigger will postback asynchronously while PostBackTrigger will do this normally... :cool:

          Abhishek Sur


          My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

          **Don't forget to click "Good Answer" if you like to.

          modified on Wednesday, November 18, 2009 4:52 PM

          M 1 Reply Last reply
          0
          • A Abhishek Sur

            AFAIK... Postback trigger will used to postback the whole page to the server... The controlId of the PostBack trigger should be the control that should invoke the Postback from within the UpdatePanel. If you want Button1 which is placed within the UpdatePanel to postback the page, rather than going for partial update, just use ControlID = "Button1" For your help, lets give you a sample code :

            <asp:UpdatePanel ID="upTest" ChildrenAsTriggers="False" UpdateMode="Conditional" runat="server">
            <ContentTemplate>
            <asp:Label ID="lblResults" runat="server"></asp:Label><br /><br />
            <asp:Button ID="btnAsync" Text="Asynch Post" runat="server" OnClick="btnAsync_Click" />
            <asp:Button ID="btnFullPost" Text="Full Post" runat="server" OnClick="btnFullPost_Click" >
            </ContentTemplate>
            <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnAsync" EventName="Click" />
            <asp:PostBackTrigger ControlID="btnFullPost" />
            </Triggers>
            </asp:UpdatePanel>

            AsyncPostBackTrigger will postback asynchronously while PostBackTrigger will do this normally... :cool:

            Abhishek Sur


            My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

            **Don't forget to click "Good Answer" if you like to.

            modified on Wednesday, November 18, 2009 4:52 PM

            M Offline
            M Offline
            macupryk
            wrote on last edited by
            #5

            I have the same problem can you take a look: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ctrlUserProfilePics.ascx.cs" Inherits="OmegaLove.Web.UI.ctrlUserProfilePics" %> <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> <%--<%@ Register Src="ctrlGPStatusBox.ascx" TagName="ctrlGPStatusBox" TagPrefix="uc1" %> --%> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <br /> <div id="UploadArea"> <table> <tr> <td> Browse Image: </td> <td> <asp:FileUpload ID="FileUpload1" runat="server" /> </td> </tr> </table> </div> <p> <asp:Button ID="UploadButton" runat="server" Text="Upload Now" OnClick="UploadButton_Click" /> </p>                 <asp:Label ID="lblResult" runat="server" ForeColor="#0066FF"></asp:Label> </ContentTemplate> <Triggers> <asp:PostBackTrigger ControlID="UploadButton" /> </Triggers> </asp:UpdatePanel> <br /> <hr /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="5" GridLines="None" ShowHeader="False"> <Columns> asp:TemplateField <ItemTemplate> <asp:Image ID="imgSaved" runat="server" ImageUrl='<%# imageURL(DataBinder.Eval(Container.DataItem, "img_id").ToString()) %>' AlternateText='<%#DataBinder.Eval(Container.DataItem,"img_title") %>' /> </ItemTemplate> </asp:TemplateField> </Columns> <EmptyDataTemplate> No records found </EmptyDataTemplate> </asp:GridView>

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups