编辑Gridview中的文件上载不工作更新面板ajax[英] FileUpload in Edit Gridview is not working update panel ajax

本文是小编为大家收集整理的关于编辑Gridview中的文件上载不工作更新面板ajax的处理方法,想解了编辑Gridview中的文件上载不工作更新面板ajax的问题怎么解决?编辑Gridview中的文件上载不工作更新面板ajax问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我有一些像产品标题、数量、价格、图片等字段的网格视图.
但是当我编辑图像值时,它没有更新.我使用了更新面板..
但删除更新面板它工作正常.
但想使用更新面板请使用文件上传更新面板的任何想法..



我的aspx代码...

<%@ 页面 语言="C#" AutoEventWireup="true" CodeBehind="GridProduct.aspx.cs" 继承="AssignFirst.GridProduct" %><%@ 注册 程序集="AjaxControlToolkit" 命名空间="AjaxControlToolkit" 标签前缀="asp" %><!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title></title><style type="text/css">.Gridview{font-family:Verdana;font-size:11pt;font-weight:正常;color:黑色;宽度:350px;}.链接按钮{颜色:黑色;}.highlight {文字装饰: none;color:黑色;背景:黄色;}</style></head><body><form id="form1" runat="server"><asp:TextBox ID="TextBox1" runat="服务器" ontextchanged="TextBox1_TextChanged"></asp:TextBox><asp:Button ID="Button2" runat="服务器" 文本="搜索" onclick="Button2_Click"CausesValidation="False" /><br /><br /><asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" /><asp:UpdatePanel ID="UpdatePanel1" runat="服务器" UpdateMode="有条件的"><ContentTemplate><asp:GridView ID="GridView1" runat="服务器" AutoGenerateColumns="False"DataKeyNames="prod_id"AllowPaging="True"CellPadding="3"PageSize="5" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="无"BorderWidth="1px" CellSpacing="2"onrowcancelingedit="GridView1_RowCancelingEdit"onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"onrowupdating="GridView1_RowUpdating"onrowcommand="GridView1_RowCommand"onrowdatabound="GridView1_RowDataBound" ondatabound="GridView1_DataBound"onrowcreated="GridView1_RowCreated"onpageindexchange="GridView1_PageIndexChanging"onsorting="GridView1_Sorting" AllowSorting="True" onrowupdated="GridView1_RowUpdated"emptydatatext="未找到记录." ><AlternatingRowStyle BackColor="White" /><><asp:TemplateField HeaderText="Prod Id" SortExpression="prod_id"><ItemTemplate><asp:Label ID="lblprodid" runat="服务器" 文本='<%#Eval("prod_id") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Prod Title" SortExpression="prod_title"><ItemTemplate><asp:Label ID="lbltitle" 文本='<%# HighlightText(Eval("prod_title").ToString()) %>' runat="server"/></ItemTemplate><EditItemTemplate><asp:TextBox ID="txttitle" runat="服务器" 文本='<%#Eval("prod_title") %>'></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txttitle1" runat="服务器"></asp:文本框></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="产品价格" SortExpression="prod_price"><ItemTemplate><asp:Label ID="lblprice" runat="服务器" 文本='<%#Eval("prod_price") %>'></asp:Label></ItemTemplate><EditItemTemplate><br /><br /><asp:TextBox ID="txtprice" runat="服务器" 文本='<%#Eval("prod_price") %>'CausesValidation="True"></asp:TextBox><br /><asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="服务器"ControlToValidate="txtprice" ErrorMessage="价格应该是数字"ValidationExpression="^\d+$"></asp:RegularExpressionValidator><br /></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtprice1" runat="服务器"></asp:文本框></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Prod Qty" SortExpression="prod_Qty"><ItemTemplate><asp:Label ID="lblqty" runat="服务器" 文本='<%#Eval("prod_Qty") %>'></asp:Label></ItemTemplate><EditItemTemplate><br /><asp:TextBox ID="txtqty" runat="服务器" 文本='<%#Eval("prod_Qty") %>'CausesValidation="True"></asp:TextBox><br /><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="服务器"ControlToValidate="txtqty" ErrorMessage="数量应该是数字"ValidationExpression="^\d+$"></asp:RegularExpressionValidator><br /></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtqty1" runat="服务器"></asp:文本框></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Prod Image" SortExpression="prod_imgpath"><ItemTemplate><%-- <asp:Label ID="lblimgpath" runat="server" Text='<%#Eval("prod_imgpath") %>'></asp:Label>--%><img id="im1" runat="server" src='<%#Eval("prod_imgpath",@"Images/{0}")%>' 高度="60" 宽度="90"alt=""/></ItemTemplate><EditItemTemplate><%-- <asp:FileUpload ID="FileUpload1"FileName='<%# Eval("prod_imgpath",@"Images/{0}") %>'runat="server"/>--%><asp:AsyncFileUpload ID="AsyncFileUpload1"OnClientUploadComplete="uploadComplete"文件名='<%# Eval("prod_imgpath",@"图片/{0}") %>' runat="服务器"></asp:AsyncFileUpload><asp:TextBox ID="txtImage" runat="服务器" 文本='<%#Eval("prod_imgpath",@"Images/{0}")%>' 可见="False"></asp:TextBox></EditItemTemplate><InsertItemTemplate><asp:FileUpload ID="FileUpload1" 文件名='<%#Eval("prod_imgpath",@"图片/{0}")%>' runat="服务器"/>跨度></InsertItemTemplate><FooterTemplate><asp:TextBox ID="txtimgpath1" runat="服务器"></asp:文本框></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="产品描述" SortExpression="prod_desc"><ItemTemplate><asp:Label ID="lbldesc" runat="服务器" 文本='<%#Eval("prod_desc") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="txtdesc" runat="服务器" 文本='<%#Eval("prod_desc") %>'TextMode="MultiLine"></asp:TextBox><br /></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtdesc1" runat="server"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Prod IsEnabled" SortExpression="prod_isenabled"><ItemTemplate><asp:Label ID="lblenabled" runat="server" Text='<%#Eval("prod_isenabled") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:RadioButtonList ID="Radio1" runat="server"><asp:ListItem></asp:ListItem><asp:ListItem>False</asp:ListItem></asp:RadioButtonList></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtenabled1" runat="server"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Prod IsDeleted" SortExpression="prod_isdeleted"><ItemTemplate><asp:Label ID="lbldeleted" runat="server" Text='<%#Eval("prod_isdeleted") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:RadioButtonList ID="Radio2" runat="server"><asp:ListItem></asp:ListItem><asp:ListItem>False</asp:ListItem></asp:RadioButtonList></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtdeleted1" runat="server"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="编辑"><ItemTemplate><asp:LinkButton ID="btnEdit" Text="Edit" runat="server" CommandName="Edit" /><br /><%--<span onclick="return confirm('Are you sure you want to delete this record?')"><asp:LinkButton ID="btnDelete" Text="Delete" runat="server" CommandName="Delete"/></span>--%><asp:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server"TargetControlID="btnDelete" ConfirmText="Are you sure you want to Delete this record?"></asp:ConfirmButtonExtender><asp:LinkButton ID="btnDelete" Text="Delete" runat="server" CommandName="Delete"/></ItemTemplate><EditItemTemplate><asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"TargetControlID="btnUpdate" ConfirmText="Are you sure you want to Update this?"OnClientCancel="CancelClick"></asp:ConfirmButtonExtender><asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" /><br /><asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" /></EditItemTemplate></asp:TemplateField></Columns><FooterStyle BackColor="#CCCC99" /><HeaderStyle BackColor="#6B696B" Font-Bold="真" ForeColor="白色" /><PagerStyle BackColor="#F7F7DE" ForeColor="黑色" Horizo​​ntalAlign="右" /><RowStyle BackColor="#F7F7DE" /><SelectedRowStyle BackColor="#CE5D5A" Font-Bold="真" ForeColor="白色" /><SortedAscendingCellStyle BackColor="#FBFBF2" /><SortedAscendingHeaderStyle BackColor="#848384" /><SortedDescendingCellStyle BackColor="#EAEAD3" /><SortedDescendingHeaderStyle BackColor="#575357" /><PagerTemplate>Goto Page<asp:DropDownList ID="ddlPageSelector" runat="server" AutoPostBack="true"></asp:DropDownList><asp:LinkButton ID="LinkButton1" runat="server" CommandName="Page" CommandArgument="First" CssClass="Linkbutton">First</asp:LinkButton><asp:LinkButton ID="LinkButton2" runat="server" CommandName="Page" CommandArgument="Prev" CssClass="Linkbutton">Pre</asp:LinkBut​​ton><asp:Label ID="CurrentPage" runat="server" Text="Label"></asp:Label><asp:LinkButton ID="LinkButton3" runat="server" CommandName="Page" CommandArgument="Next" CssClass="Linkbutton">Next</asp:LinkButton><asp:LinkButton ID="LinkButton4" runat="server" CommandName="Page" CommandArgument="Last" CssClass="Linkbutton">Last</asp:LinkButton><br /></PagerTemplate></asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server"ConnectionString="<%$ ConnectionStrings:ConnectionString %>"SelectCommand="SELECT * FROM [Product]"><UpdateParameters><asp:Parameter Name="prod_title" /><asp:Parameter Name="prod_price" /><asp:Parameter Name="prod_Qty" /><asp:Parameter Name="prod_imgpath" /><asp:Parameter Name="prod_desc" /><asp:Parameter Name="prod_isenabled" /><asp:Parameter Name="prod_isdeleted" /></UpdateParameters></asp:SqlDataSource></ContentTemplate></asp:UpdatePanel><div><asp:Button ID="Button1" runat="server" PostBackUrl="~/product.aspx"Text="Add Product" Width="145px" style="margin-left: 30px" /></div></form></body></html>

推荐答案

"></asp:RegularExpressionValidator><br /></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtprice1" runat="server"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Prod Qty" SortExpression="prod_Qty"><ItemTemplate><asp:Label ID="lblqty" runat="server" Text='<%#Eval("prod_Qty") %>'></asp:Label></ItemTemplate><EditItemTemplate><br /><asp:TextBox ID="txtqty" runat="server" Text='<%#Eval("prod_Qty") %>'CausesValidation="True"></asp:TextBox><br /><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"ControlToValidate="txtqty" ErrorMessage="Qty Should be Numeric"ValidationExpression="^\d+

"></asp:RegularExpressionValidator><br /></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtqty1" runat="server"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Prod Image" SortExpression="prod_imgpath"><ItemTemplate><%-- <asp:Label ID="lblimgpath" runat="server" Text='<%#Eval("prod_imgpath") %>' ></asp:Label>--%><img id="im1" runat="server" src='<%#Eval("prod_imgpath",@"Images/{0}")%>' height="60" width="90" alt=""/></ItemTemplate><EditItemTemplate><%-- <asp:FileUpload ID="FileUpload1"FileName='<%# Eval("prod_imgpath",@"Images/{0}") %>' runat="server"/>--%><asp:AsyncFileUpload ID="AsyncFileUpload1"OnClientUploadComplete="uploadComplete"FileName='<%# Eval("prod_imgpath",@"Images/{0}") %>' runat="server"></asp:AsyncFileUpload><asp:TextBox ID="txtImage" runat="server" Text='<%#Eval("prod_imgpath",@"Images/{0}")%>' Visible="False"></asp:TextBox></EditItemTemplate><InsertItemTemplate><asp:FileUpload ID="FileUpload1" FileName='<%#Eval("prod_imgpath",@"Images/{0}")%>' runat="server"/></InsertItemTemplate><FooterTemplate><asp:TextBox ID="txtimgpath1" runat="server"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Prod Desc" SortExpression="prod_desc"><ItemTemplate><asp:Label ID="lbldesc" runat="server" Text='<%#Eval("prod_desc") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:TextBox ID="txtdesc" runat="server" Text='<%#Eval("prod_desc") %>'TextMode="MultiLine"></asp:TextBox><br /></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtdesc1" runat="server"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Prod IsEnabled" SortExpression="prod_isenabled"><ItemTemplate><asp:Label ID="lblenabled" runat="server" Text='<%#Eval("prod_isenabled") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:RadioButtonList ID="Radio1" runat="server"><asp:ListItem></asp:ListItem><asp:ListItem>False</asp:ListItem></asp:RadioButtonList></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtenabled1" runat="server"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="Prod IsDeleted" SortExpression="prod_isdeleted"><ItemTemplate><asp:Label ID="lbldeleted" runat="server" Text='<%#Eval("prod_isdeleted") %>'></asp:Label></ItemTemplate><EditItemTemplate><asp:RadioButtonList ID="Radio2" runat="server"><asp:ListItem></asp:ListItem><asp:ListItem>False</asp:ListItem></asp:RadioButtonList></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtdeleted1" runat="server"></asp:TextBox></FooterTemplate></asp:TemplateField><asp:TemplateField HeaderText="编辑"><ItemTemplate><asp:LinkButton ID="btnEdit" Text="Edit" runat="server" CommandName="Edit" /><br /><%--<span onclick="return confirm('Are you sure you want to delete this record?')"><asp:LinkButton ID="btnDelete" Text="Delete" runat="server" CommandName="Delete"/></span>--%><asp:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server"TargetControlID="btnDelete" ConfirmText="Are you sure you want to Delete this record?"></asp:ConfirmButtonExtender><asp:LinkButton ID="btnDelete" Text="Delete" runat="server" CommandName="Delete"/></ItemTemplate><EditItemTemplate><asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"TargetControlID="btnUpdate" ConfirmText="Are you sure you want to Update this?"OnClientCancel="CancelClick"></asp:ConfirmButtonExtender><asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" /><br /><asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" /></EditItemTemplate></asp:TemplateField></Columns><FooterStyle BackColor="#CCCC99" /><HeaderStyle BackColor="#6B696B" Font-Bold="真" ForeColor="白色" /><PagerStyle BackColor="#F7F7DE" ForeColor="黑色" Horizo​​ntalAlign="右" /><RowStyle BackColor="#F7F7DE" /><SelectedRowStyle BackColor="#CE5D5A" Font-Bold="真" ForeColor="白色" /><SortedAscendingCellStyle BackColor="#FBFBF2" /><SortedAscendingHeaderStyle BackColor="#848384" /><SortedDescendingCellStyle BackColor="#EAEAD3" /><SortedDescendingHeaderStyle BackColor="#575357" /><PagerTemplate>Goto Page<asp:DropDownList ID="ddlPageSelector" runat="server" AutoPostBack="true"></asp:DropDownList><asp:LinkButton ID="LinkButton1" runat="server" CommandName="Page" CommandArgument="First" CssClass="Linkbutton">First</asp:LinkButton><asp:LinkButton ID="LinkButton2" runat="server" CommandName="Page" CommandArgument="Prev" CssClass="Linkbutton">Pre</asp:LinkBut​​ton><asp:Label ID="CurrentPage" runat="server" Text="Label"></asp:Label><asp:LinkButton ID="LinkButton3" runat="server" CommandName="Page" CommandArgument="Next" CssClass="Linkbutton">Next</asp:LinkButton><asp:LinkButton ID="LinkButton4" runat="server" CommandName="Page" CommandArgument="Last" CssClass="Linkbutton">Last</asp:LinkButton><br /></PagerTemplate></asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server"ConnectionString="<%

ConnectionStrings:ConnectionString %>"SelectCommand="SELECT * FROM [Product]"><UpdateParameters><asp:Parameter Name="prod_title" /><asp:Parameter Name="prod_price" /><asp:Parameter Name="prod_Qty" /><asp:Parameter Name="prod_imgpath" /><asp:Parameter Name="prod_desc" /><asp:Parameter Name="prod_isenabled" /><asp:Parameter Name="prod_isdeleted" /></UpdateParameters></asp:SqlDataSource></ContentTemplate></asp:UpdatePanel><div><asp:Button ID="Button1" runat="server" PostBackUrl="~/product.aspx"Text="Add Product" Width="145px" style="margin-left: 30px" /></div></form></body></html>

本文地址:https://www.itbaoku.cn/post/1355814.html