Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 3 tables std,srv,bsn
i bind all 3 tables with single gridview separately.
now when i trying to edit a row throught GridView1_RowEditing(object sender, GridViewEditEventArgs e) method i can't bind the grid with 3 different table data
how can i solve this?

What I have tried:

C#
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowEditing="GridView1_RowEditing" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" > 
                        <AlternatingRowStyle BackColor="White" />
                        <columns>
                            <asp:TemplateField HeaderText="ID">
                                <itemtemplate>
                                    <asp:Label ID="id" runat="server" Text='<%# Eval("id") %>'/>
                                
                            
                            <asp:TemplateField HeaderText="NAME">
                                <itemtemplate>
                                    <asp:Label ID="name" runat="server" Text='<%# Eval("name") %>'/>
                                
                                <edititemtemplate>
                                    <asp:TextBox ID="txtname" runat="server" Text='<%# Eval("name") %>'>
                                
                            
                            <asp:TemplateField HeaderText="AGE">
                                <itemtemplate>
                                    <asp:Label ID="age" runat="server" Text='<%# Eval("age") %>'/>
                                
                                <edititemtemplate>
                                    <asp:TextBox ID="txtage" runat="server" Text='<%# Eval("age") %>'>
                                
                            
                            <asp:TemplateField HeaderText="GENDER">
                                <itemtemplate>
                                    <asp:Label ID="gender" runat="server" Text='<%# Eval("gender") %>'/>
                                
                                <edititemtemplate>
                                    <asp:TextBox ID="txtgender" runat="server" Text='<%# Eval("gender") %>'>
                                
                            
                            <asp:TemplateField HeaderText="PROFESSION">
                                <itemtemplate>
                                    <asp:Label ID="profession" runat="server" Text='<%# Eval("profession") %>'/>
                                
                               
                            
                            <asp:templatefield>
                                <itemtemplate>
                                    <asp:Button ID="editbtn" Text="EDIT" runat="server" CommandName="Edit" /> 
                                
                                <edititemtemplate>
                                   <asp:Button ID="updatebtn" Text="UPDATE" runat="server" CommandName="Update" />
                                   <asp:Button ID="cancelbtn" Text="CANCEL" runat="server" CommandName="Cancel" />
                                
                            
                            <asp:templatefield>
                                <itemtemplate>
                                    <asp:Button ID="deletebtn" Text="DELETE" runat="server" CommandName="Delete" /> 
                                
                            

                        
                        <EditRowStyle BackColor="#7C6F57" />
                        <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#E3EAEB" />
                        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#F8FAFA" />
                        <SortedAscendingHeaderStyle BackColor="#246B61" />
                        <SortedDescendingCellStyle BackColor="#D4DFE1" />
                        <SortedDescendingHeaderStyle BackColor="#15524A" />
Posted
Updated 16-May-18 3:19am
v2
Comments
Richard Deeming 17-May-18 10:57am    
Your EditItemTemplates should be using <%# Bind("...") %> instead of <%# Eval("...") %>:
<editItemTemplate>
    <asp:TextBox ID="txtname" runat="server" Text='<%# Bind("name") %>' />
</editItemTemplate>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900