gridview中的文件上传控件 [英] Fileupload control in gridview

查看:83
本文介绍了gridview中的文件上传控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个绑定到数据库的gridview,它具有FileUpload控件的模板字段.此外,在gridview的页脚模板中还有一个Submit按钮,单击该按钮时,将提交gridview中的整个数据. >
现在页面继承了母版页面,并且页面内部具有更新面板.问题是当我单击提交"按钮时,数据字段已提交,但我插入的文件未插入/保存.

我知道除非并直到给出提交提交按钮的回发触发器,否则文件上传控件不起作用..但是我如何为gridview的页脚模板中的按钮编写回发触发器..我已经尝试过了,但是它在下面给了我错误:

在UpdatePanel"upSchool"中找不到ID为"btnSubmit"的控件作为触发器.

这是代码:

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 :

<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>




请帮忙..

问候,
Krunal Panchal




Please help..

Regards,
Krunal Panchal

推荐答案

hii ,

use this as item template or footer template
this will work

hii ,

use this as item template or footer template
this will work

<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




where btn_add is your add buttons id


这篇关于gridview中的文件上传控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆