0

Dear friends,

I have a tab container with many tab panels in it. In each tab panel, I have a GridView which has an Edit button in each row. When Edit button is pressed, it turns into an Update button, and all fields become editable. When the Update button is pressed, the values are saved in the database.
I have 2 problems:
1) On pressing the Edit button, sometimes nothing happens, sometimes it works properly.
I noticed that Edit always works if I first refresh the page.
When the Edit button works on one tab panel, and I change tab, on another tab panel it doesn't work, the Edit button handler is not called, and when I press Edit, the TabChanged handler is called instead.
2) On pressing Update button, DBInterfaceGridView_RowUpdating() is not executed, thus nothing is saved.

<ajaxToolkit:TabContainer ID="tcDBInterface" runat="server" 
    ActiveTabIndex="16" OnClientActiveTabChanged="clientActiveTabChanged" 
    Width="5100" style="margin-right: 53px" 
    onactivetabchanged="tcDBInterface_ActiveTabChanged" > 
        <ajaxToolkit:TabPanel runat="server" HeaderText="AuthourLinks" ID="AuthorLinksTabPanel" >
            <HeaderTemplate>
                AuthourLinks
            </HeaderTemplate>
            <ContentTemplate>     
             
                <asp:UpdatePanel ID="upnlAuthorLinks" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>                  
               
                    <asp:ValidationSummary ID="AuthorLinksValidationSummary" runat="server" 
                        BorderStyle="Solid" HeaderText="The following error(s) occured:" />      

                    <asp:GridView ID="AuthorLinksGridView" runat="server" AllowSorting="True" ShowFooter="True"
                            AllowPaging="True" PageSize="15" DataSourceID="AuthorLinksSqlDataSource" 
                            OnRowDataBound="DBInterfaceGridView_RowDataBound" AutoGenerateColumns="False" 
                            OnRowUpdating="DBInterfaceGridView_RowUpdating"    
                            OnRowDeleting="DBInterfaceGridView_RowDeleting"  
                            Width="800px" Height="306px"  DataKeyNames="ID" 
                            CssClass="largegridview" Visible="False" 
                            onrowediting="DBInterfaceGridView_RowEditing" >
                    <AlternatingRowStyle CssClass="alternatingrowstyle" />
                    <Columns>
                         <asp:TemplateField>  
                            <ItemTemplate>   
                                <asp:ImageButton ID="btnEdit"   runat="server" Text="Edit"      CommandName="Edit"   ImageUrl="~/Images/Edit.gif"   ToolTip="Edit"   CausesValidation="False"></asp:ImageButton>  
                                <asp:ImageButton ID="btnDelete" runat="server" Text="Delete"    CommandName="Delete" ImageUrl="~/Images/Delete.gif" ToolTip="Delete" CausesValidation="False" OnClientClick = "return confirm('Are you sure you want to delete this record?')"></asp:ImageButton>  
                            </ItemTemplate>  
                            <EditItemTemplate>   
                                <asp:ImageButton ID="btnUpdate" runat="server" Text="Update"    CommandName="Update" ImageUrl="~/Images/Update.gif" ToolTip="Update" OnClientClick = "return confirm('Are you sure you want to update this record?')"></asp:ImageButton>  
                                <asp:ImageButton ID="btnCancel" runat="server" Text="Cancel"    CommandName="Cancel" ImageUrl="~/Images/Cancel.gif" ToolTip="Cancel" CausesValidation="False"></asp:ImageButton>  
                            </EditItemTemplate>    
                            <FooterTemplate>
                                <asp:ImageButton ID="btnAddNew"    runat="server" CommandName="AddNew"  Text="Add New Record"  ImageUrl="~/Images/Insert.gif" ToolTip="Add New Record"  CausesValidation="False" OnClick="DBInterfaceGridView_AddNew"></asp:ImageButton>
                                <asp:ImageButton ID="btnSaveNew"   runat="server" CommandName="SaveNew" Text="Save New Record" ImageUrl="~/Images/Update.gif" ToolTip="Save New Record" Visible="false" OnClick="DBInterfaceGridView_Insert"></asp:ImageButton>
                                <asp:ImageButton ID="btnCancelNew" runat="server" CommandName="Cancel"  Text="Cancel"          ImageUrl="~/Images/Cancel.gif" ToolTip="Cancel"          CausesValidation="False" Visible="false" ></asp:ImageButton>  
                            </FooterTemplate>                                                      
                        </asp:TemplateField> 

                         <asp:TemplateField HeaderText="BookStem" SortExpression="BookStem">
                            <EditItemTemplate>    
                                <asp:DropDownList ID="BookStem" runat="server" SelectedValue='<%# Eval("BookStem") %>'
                                    DataSourceID="BookListObjectDataSource" DataTextField="BookStem" DataValueField="BookStem">
                                </asp:DropDownList>                             
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="lblBookStem" runat="server" Text='<%#Bind("BookStem") %>'></asp:Label>
                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:DropDownList ID="newBookStem" runat="server" Visible="false"
                                    DataSourceID="BookListObjectDataSource" DataTextField="BookStem" DataValueField="BookStem" >
                                </asp:DropDownList>                                       
                            </FooterTemplate>                

... many other fields

Thanks,
Dmitriy

2
Contributors
5
Replies
11
Views
7 Years
Discussion Span
Last Post by dpreznik
0

It looks like it's a problem with the ID's of the buttons. Try turn of the ID's of the buttons (ItemTemplates) in the gridview and let ASP.NET assign ID's. Maybee it works.

I also see that you use Eval for the EditItemTemplate, this can give problems, if so you sould changes this to Bind.

0

Ossehaas,
Thank you for your answer.
Unfortunately, that didn't help.
I wonder why it works after refreshing.
I cannot use Bind there, because the field should be a dropdown list.
All that used to work before I added UpdatePanels inside aeach tab panel around its contents.

0

I copied the code and it seems to be working ok on my pc. I used the same construction (Tabcontainer > UpdatePanel > GridView) so the error is not in the code you send.

0

It worked when I removed UpdatePanels... I would prefer to keep them for better performance, but what can I do...

0

That is really strange, and I cannot explain it. I removed the Update Panel and provided lazy loading by using TabChange event handler to make visible only GridView in the currently active tab.
Thank you for your help.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.