Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am trying to update the gridview row but its not working.Because I have rows from two different tables whick i have joined. But the second column is not updating. Please help.
here is my code
ASP.NET
<asp:GridView ID="gvProducts" runat="server" AutoGenerateEditButton="True" AutoGenerateColumns="False"
                OnRowEditing="gvProducts_RowEditing" 
            OnRowUpdating="gvProducts_RowUpdating" CellPadding="1"
                ForeColor="#333333" GridLines="None" DataSourceID="SqlDataSource1" 
            Height="75px" Width="660px" DataKeyNames="BranchCode" AllowPaging="True" 
            PageSize="20">
                <rowstyle backcolor="#EFF3FB" />
                <columns>
                    <asp:BoundField DataField="BranchCode" HeaderText="BranchCode" ReadOnly="True" 
                        SortExpression="BranchCode" />
                    <asp:BoundField DataField="BranchName" HeaderText="BranchName" 
                        SortExpression="BranchName" />
                    <%--<asp:BoundField DataField="TierName" HeaderText="Branch Group" 
                        SortExpression="TierName" />  --%>
                    
                    <asp:TemplateField HeaderText="Branchgroup">
                    <edititemtemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" DataSourceID="SqlDataSource1" DataTextField="TierName" DataValueField="TierName" Width="120px" Height="25px" >
                    </edititemtemplate>
                    <itemtemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("TierName") %>'>
                    </itemtemplate>
                </columns>
                <editrowstyle backcolor="#2461BF" />
                <footerstyle backcolor="#507CD1" font-bold="True" forecolor="White" />
                <pagersettings firstpagetext="First</br>" lastpagetext="Last </br>">
                    Mode="NextPrevious" NextPageText="Next</br>" 
                    PreviousPageText="Previous </br>" />
                <pagerstyle backcolor="#2461BF" forecolor="White" horizontalalign="Center" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" 
                    HorizontalAlign="Left" />
                <alternatingrowstyle backcolor="White" />
                <sortedascendingcellstyle backcolor="#F5F7FB" />
                <sortedascendingheaderstyle backcolor="#6D95E1" />
                <sorteddescendingcellstyle backcolor="#E9EBEF" />
                <sorteddescendingheaderstyle backcolor="#4870BE" />
            
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ %>"                                   
            SelectCommand="SELECT Admin_Branch.BranchCode, Admin_Branch.BranchName, Admin_Tier.TierName FROM Admin_Branch INNER JOIN Admin_Tier ON Admin_Branch.TierCode = Admin_Branch.TierCode"
             UpdateCommand="UPDATE Admin_Branch set BranchName=@BranchName where BranchCode=@BranchCode">
        </pagersettings>
Posted
Updated 8-Apr-13 22:27pm
v2
Comments
Chinmaya C 9-Apr-13 4:22am    
i think your update statement should be:
UPDATE Admin_Branch set BranchName=@BranchName where BranchCode=@original_BranchCode
Karthik Harve 9-Apr-13 4:28am    
[Edit] Code block added.
babli3 9-Apr-13 4:31am    
Thanks.Its working for 1 column but it isnt working for the other.
UPDATE Admin_Tier set TierName=@TierName where TierCode=@TierCode .
Is it possible to join these two update statements?

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