Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,

I have one gridview which is bound to database and it has template field of FileUpload control.. Moreover there is a submit button in footer template of gridview , and on the click of that button the whole data in the gridview is submitted.

Now the page inherits master page and it has update panel inside it..The problem is when i click on submit button the data field are submitted but the files which i uploaded are not inserted/saved.

I know that fileupload control doesn't works unless and until postback trigger to submit button is given..but how do i write postback trigger for the button which is in footer template of gridview.. i have tried it but it gave me below error :

A control with ID 'btnSubmit' could not be found for the trigger in UpdatePanel 'upSchool'.

Here is the code :

XML
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:UpdateProgress ID="upProgressSchool" runat ="server" AssociatedUpdatePanelID ="upSchool">
    <ProgressTemplate >
         <div id="overlay"  style="position:absolute;width:2000px;height:2000px;opacity: .8;filter: alpha(opacity=80);z-index:99999;left:0px;top:0px;">
            <img src="_img/loading.gif" style="padding-top:500px;padding-left:600px;">
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upSchool" runat ="server">
    <ContentTemplate >
            <fieldset >
                <legend><table class="legend"><tr><td>Release Entry</td></tr></table></legend>
                <table align="center">
                    <tr>
                        <td>
                            <asp:Label ID="lbMessage" runat ="server" ></asp:Label>
                        </td>
                    </tr>
                </table>
                <br />
                <table align="center">
                    <tr>
                        <td>
                            <asp:Label ID ="lbSchoolsPending" runat ="server" Text="Schools Pending " ForeColor ="Black"></asp:Label>
                        </td>
                    </tr>
                </table>
                <br />
                <table align="center">
                    <tr>
                        <td>
                            <asp:GridView ID ="gdvTobeReleasedSchool" runat ="server"
                                AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC"
                                BorderStyle="None" BorderWidth="1px" CellPadding="3"
                                EnableModelValidation="True" ShowFooter="True"
                                onrowcommand="gdvTobeReleasedSchool_RowCommand" >
                                <Columns>
                                   <asp:TemplateField HeaderText="Sr.No.">
                                                            <ItemTemplate>
                                                                <asp:Label ID ="lbSchoolId" runat ="server" Text='<%#Container.DataItemIndex+1 %>' ToolTip ='<%#Eval("SchoolId") %>'></asp:Label>
                                                            </ItemTemplate>
                                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
                                                        </asp:TemplateField>
                                                        <asp:TemplateField HeaderText="School Name">
                                                            <ItemTemplate>
                                                                <asp:Label ID ="lbSchoolName" runat ="server" Text='<%#Eval("SchoolName") %>' ToolTip ='<%#Eval("SchoolId") %>'></asp:Label>
                                                            </ItemTemplate>
                                                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="500px" />
                                                        </asp:TemplateField>
                                                        <asp:BoundField DataField="CustomerCode" HeaderText="Customer Code">
                                                          <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="200px" />
                                                          </asp:BoundField>
                                    <asp:BoundField DataField="StateName" HeaderText="State">
                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="300px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="CityName" HeaderText="City">
                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="300px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="Classes" HeaderText="No. of Classes">
                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="KnowledgeCafe" HeaderText="No. of Knowledge cafe">
                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="AgreementDate" DataFormatString="{0:dd/MM/yyyy}"
                                        HeaderText="Agreement Date">
                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="200px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="FinanceDate" HeaderText="Finance Date" DataFormatString="{0:dd/MM/yyyy}">
                                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="200px" />
                                    </asp:BoundField>
                                    <asp:TemplateField HeaderText="SO Release Date">
                                        <ItemTemplate >
                                            <asp:TextBox ID ="txtSOReleaseDate" runat ="server" Height ="20px" Width ="100px"></asp:TextBox>
                                            <cc1:CalendarExtender ID="calReleaseDate" runat ="server" OnClientDateSelectionChanged="checkDate" Format ="yyyy-MM-dd" TargetControlID ="txtSOReleaseDate"></cc1:CalendarExtender>
                                        </ItemTemplate>

                                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Remarks">
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtRemarks" runat ="server" Height ="20px" Width ="300px"></asp:TextBox>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="300px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Is Road Permit">
                                        <ItemTemplate >
                                            <asp:CheckBox ID="chkRoadPermit" runat ="server" />
                                        </ItemTemplate>

                                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText ="Upload File">
                                        <ItemTemplate >
                                            <asp:FileUpload ID="fpUpload" runat ="server" />
                                        </ItemTemplate>
                                         <FooterTemplate >
                                            <asp:Button ID="btnSubmit" runat ="server" Text="Submit" cssclass="button" CommandName ="SubmitReleaseSchools" />
                                        </FooterTemplate>
                                        <FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="300px" />
                                    </asp:TemplateField>
                                </Columns>
                                <FooterStyle BackColor="White" ForeColor="#000066" />
                                <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                                <RowStyle ForeColor="#000066" />
                                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                            </asp:GridView>
                        </td>
                    </tr>
                </table>
 </fieldset>
        </ContentTemplate>
        <Triggers>
            <asp:PostBackTrigger  ControlID ="btnSubmit" />
        </Triggers>
  </asp:UpdatePanel>



Please help..

Regards,
Krunal Panchal
Posted
Updated 10-Aug-12 15:11pm
v3
Comments
bbirajdar 10-Aug-12 9:33am    
Show us the code...btnSubmit and upSchool should be in the same ItemTemplate
[no name] 10-Aug-12 9:41am    
HI,

I am sorry , but i update my question and have inserted the code..

Pls help
Regards,
Krunal

1 solution

hii ,

use this as item template or footer template
this will work

XML
<asp:UpdatePanel id="UpdatePanel3" runat="server" __designer:wfdid="w26">
                                                        <contenttemplate>
<asp:FileUpload style="VERTICAL-ALIGN: top; TEXT-ALIGN: left" id="FileUpload_claim_doc" runat="server" __designer:wfdid="w27" size=5></asp:FileUpload>&nbsp;<BR />
</contenttemplate>
                                                        <triggers>
<asp:PostBackTrigger ControlID="btn_add"></asp:PostBackTrigger>
</triggers>
                                                    </asp:UpdatePanel>



where btn_add is your add buttons id
 
Share this answer
 
v3
Comments
[no name] 13-Aug-12 1:22am    
Hi,

I think that you have not understood my question, I need postback trigger on the button which is inside gridview footertemplate..

Please help me..

Regards,
Krunal

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900