Hello, There was no problem before using UpdatePanel. RowDeleting and RowUpdating is perfectly fired with image. But when I wrap my GridView with UpdatePanel the RowUpdating Panel not working however the RowDeleting is still working. Here is my GridView design:
Code for grid view:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="gID" DataSourceID="LinqDataSource1" onrowdeleting="GridView1_RowDeleting" onrowupdating="GridView1_RowUpdating" CellPadding="4" ForeColor="#333333" GridLines="None" Width="244px" ShowHeader="False"><AlternatingRowStyle BackColor="White" ForeColor="#284775" /><Columns><asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /><asp:TemplateField HeaderText="gID" InsertVisible="False" SortExpression="gID"><EditItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Eval("gID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Eval("gID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="i"><EditItemTemplate><asp:FileUpload ID="FileUploadRowEdit" runat="server" /></EditItemTemplate><ItemTemplate><asp:Image ID="Image1" runat="server" Height="40px" ImageUrl='<%# Eval("PhotoName", "~/Gallery/{0}") %>' Width="40px" /></ItemTemplate><ControlStyle Height="40px" Width="40px" /></asp:TemplateField><asp:BoundField DataField="PortID" HeaderText="PortID" SortExpression="PortID" /></Columns><EditRowStyle BackColor="#999999" /><FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /><RowStyle BackColor="#F7F6F3" ForeColor="#333333" /><SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /><SortedAscendingCellStyle BackColor="#E9E7E2" /><SortedAscendingHeaderStyle BackColor="#506C8C" /><SortedDescendingCellStyle BackColor="#FFFDF8" /><SortedDescendingHeaderStyle BackColor="#6F8DAE" /></asp:GridView><asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="ImonPortdbDataContext" EnableDelete="True" EnableInsert="True" EnableUpdate="True" EntityTypeName="" TableName="Galleries" Where="PortID == @PortID"><WhereParameters><asp:QueryStringParameter Name="PortID" QueryStringField="id" Type="Int32" /></WhereParameters></asp:LinqDataSource></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="GridView1" EventName="RowUpdating"/></Triggers></asp:UpdatePanel>
And code for RowUpdading Event is:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { db = new ImonPortdbDataContext(); FileUpload fu = (FileUpload)GridView1.Rows[e.RowIndex].FindControl("FileUploadRowEdit"); Label lbl = (Label)GridView1.Rows[e.RowIndex].FindControl("Label1"); int lbImglId = Convert.ToInt32(lbl.Text); var imgName = db.Galleries.Where(s => s.gID == lbImglId).First(); if (fu.HasFile) { System.IO.File.Delete(Server.MapPath("~/Gallery/" + imgName.PhotoName)); fu.SaveAs(Server.MapPath("~/Gallery/" + fu.FileName)); e.NewValues["PhotoName"] = fu.FileName; } }
Is it possible? If so, How do I fix it?
best regards
ehsan