GridView inside UpdatePanel not Uploading Image
-
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
-
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
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.
-
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.
-
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......
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 whilePostBackTrigger
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
-
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 whilePostBackTrigger
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
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>