Odd. EditIndex = -1 and DataBind should do the trick. Does it show any of the messages in the label?
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
As long as both the originator of the event, and the bit that needs update are inside the same UpdatePanel, there should be no problem. Even using the Update method of the UpdatePanel should not be necessary.
However, I think I see the problem. Your GridView isn't hooked up to the RowUpdating handler you made. So not only does it not update the GridView. It doesn't update at all. You get an Exception for that.
And that is where UpdatePanel has a bit of nasty behavior. Instead of notifying you there is an Exception, it simply throws it away. So you get no update, and no visible Exception. It looks like nothing at all happened.
I make a habit out of building pages without UpdatePanel first. Once I have a fully working page, I put in UpdatePanels where needed. This helps a lot with cases like this one.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
a_elnajjar82
Member
84 Points
107 Posts
Problem with Grid View
Aug 03, 2012 04:39 PM|LINK
Hi
I had some problem in grid view control . when I try to update Entry it wouldn't close the edit mode? can somone help me
protected void gv_billingList_RowUpdating(object sender, GridViewUpdateEventArgs e) { Guid billingID = Guid.Parse(gv_billingList.DataKeys[e.RowIndex].Value.ToString()); string billingNumber = ((TextBox)gv_billingList.Rows[e.RowIndex].FindControl("txtb_billingNumber")).Text; bool isCompleted = ((CheckBox)gv_billingList.Rows[e.RowIndex].FindControl("chb_isCompleted")).Checked; if (isCompleted == true) { // Execute the update command bool success = BillingsTimes.UpdateBillingTime(billingID, billingNumber, isCompleted); //exit edit mode gv_billingList.EditIndex = -1; //databind // Display status message if (success == true) { gv_billingList.EditIndex = -1; lblMassage.Text = "Billings Times update successful"; gv_billingList.DataBind(); } else { gv_billingList.EditIndex = -1; lblMassage.Text = "Billings Times update failed "; gv_billingList.DataBind(); } } else { gv_billingList.EditIndex = -1; lblMassage.Text = "Billings Times update failed please set billing to complete"; gv_billingList.DataBind(); } }Keyur Shah
Participant
1002 Points
278 Posts
Re: Problem with Grid View
Aug 04, 2012 05:25 AM|LINK
Is it allows you to updae the entry? I mean it closes edit mode after updation of before?
If it closes the edit mode after updation then its obvious that you can do operation in sequence like 1)EDIT OR DELETE 2)UPDATE OR CANCEL.
Hope you are clear if not then let me know.
superguppie
All-Star
48225 Points
8679 Posts
Re: Problem with Grid View
Aug 06, 2012 09:17 AM|LINK
Odd. EditIndex = -1 and DataBind should do the trick. Does it show any of the messages in the label?
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
aruna.puja
Member
511 Points
175 Posts
Re: Problem with Grid View
Aug 06, 2012 09:22 AM|LINK
is there ny updatepanel being used?? What is the source of gridview?
a_elnajjar82
Member
84 Points
107 Posts
Re: Problem with Grid View
Aug 07, 2012 07:02 PM|LINK
Yes I used the updatepanel and one Q: is their any problem using the updatepanel ?
this the sourse code
<div id="billingsTimes_div"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:HiddenField ID="hf_userID" runat="server" Value="43D25844-5CFC-4817-BDAE-61DD797D4CFC" /> <table> <tr> <td> <asp:Label ID="Label1" runat="server" Text="Actual Total Time"></asp:Label> </td> <td> <asp:TextBox ID="txtb_totalTime" runat="server"></asp:TextBox> </td> </tr> <tr> <td style="direction: ltr"> <asp:Label ID="Label2" runat="server" Text="billable Type"></asp:Label> </td> <td> <asp:DropDownList ID="ddl_billableType" runat="server" AppendDataBoundItems="True" DataSourceID="dsSQl_billableType" DataTextField="billableTypeName" DataValueField="billableTypeID"> <asp:ListItem Value="-1">Select One</asp:ListItem> </asp:DropDownList> <asp:SqlDataSource ID="dsSQl_billableType" runat="server" ConnectionString="<%$ ConnectionStrings:Compudata_ProjectManagerConnection %>" SelectCommand="GetAllBillableType" SelectCommandType="StoredProcedure"></asp:SqlDataSource> </td> </tr> <tr> <td style="direction: ltr"> <asp:Label ID="Label4" runat="server" Text="Summary"></asp:Label> </td> <td> <asp:TextBox ID="txtb_Sammary" runat="server" TextMode="MultiLine"></asp:TextBox> </td> </tr> <tr> <td> <asp:Label ID="lblMassage" runat="server"></asp:Label> </td> <td> <asp:Button ID="btn_addBill" runat="server" Text="Add Bill" OnClick="btn_addBill_Click" /> </td> </tr> </table> <asp:GridView ID="gv_billingList" runat="server" AutoGenerateColumns="False" AutoGenerateDeleteButton="True" CellPadding="4" DataKeyNames="billingID" DataSourceID="sqlDS_GetAllbillingsTimesForTask" ForeColor="#333333" GridLines="None" onrowdeleting="gv_billingList_RowDeleting"> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:BoundField DataField="billingID" HeaderText="billingID" ReadOnly="True" SortExpression="billingID" /> <asp:BoundField DataField="User Name" HeaderText="User Name" ReadOnly="True" SortExpression="User Name" /> <asp:BoundField DataField="taskID" HeaderText="taskID" SortExpression="taskID" /> <asp:BoundField DataField="actualTotalTime" HeaderText="actualTotalTime" SortExpression="actualTotalTime" /> <asp:BoundField DataField="createdOn" HeaderText="createdOn" SortExpression="createdOn" /> <asp:BoundField DataField="billableTypeID" HeaderText="billableTypeID" SortExpression="billableTypeID" /> <asp:BoundField DataField="billingNumber" HeaderText="billingNumber" SortExpression="billingNumber" /> <asp:BoundField DataField="summary" HeaderText="summary" SortExpression="summary" /> <asp:CheckBoxField DataField="isCompleted" HeaderText="isCompleted" SortExpression="isCompleted" /> </Columns> <EditRowStyle BackColor="#2461BF" /> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#EFF3FB" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#F5F7FB" /> <SortedAscendingHeaderStyle BackColor="#6D95E1" /> <SortedDescendingCellStyle BackColor="#E9EBEF" /> <SortedDescendingHeaderStyle BackColor="#4870BE" /> </asp:GridView> <asp:SqlDataSource ID="sqlDS_GetAllbillingsTimesForTask" runat="server" ConnectionString="<%$ ConnectionStrings:Compudata_ProjectManagerConnection %>" SelectCommand="GetAllbillingsTimesForTask" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:QueryStringParameter Name="TaskID" QueryStringField="taskID" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btn_addBill" /> <asp:AsyncPostBackTrigger ControlID="gv_billingList" EventName="RowDeleting" /> </Triggers> </asp:UpdatePanel> </div> </asp:Panel>aruna.puja
Member
511 Points
175 Posts
Re: Problem with Grid View
Aug 08, 2012 09:03 AM|LINK
Sorry for the delay...
If u are using updatepanel, u need to update it in code behind whenu are binding the gridview after any event.
UpdatePanel.Update()
Ajay2707
Contributor
4487 Points
870 Posts
Re: Problem with Grid View
Aug 08, 2012 11:03 AM|LINK
Hi friend,
please check this,
http://www.codeproject.com/Articles/23471/Editable-GridView-in-ASP-NET-2-0
http://msdn.microsoft.com/en-us/library/ms972940.aspx
superguppie
All-Star
48225 Points
8679 Posts
Re: Problem with Grid View
Aug 09, 2012 11:32 AM|LINK
As long as both the originator of the event, and the bit that needs update are inside the same UpdatePanel, there should be no problem. Even using the Update method of the UpdatePanel should not be necessary.
However, I think I see the problem. Your GridView isn't hooked up to the RowUpdating handler you made. So not only does it not update the GridView. It doesn't update at all. You get an Exception for that.
And that is where UpdatePanel has a bit of nasty behavior. Instead of notifying you there is an Exception, it simply throws it away. So you get no update, and no visible Exception. It looks like nothing at all happened.
I make a habit out of building pages without UpdatePanel first. Once I have a fully working page, I put in UpdatePanels where needed. This helps a lot with cases like this one.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.