Click here to Skip to main content
15,912,507 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I have three tables......

1.Categorycrt
productid(primary key)
  productcategory
  Girthfrom
  GirthTo


2.Itemcre
Itemid(primary key)
Itemname
  </pre lang="text">
3.Pricefix
<pre lang="vb">PriceId(primarykey)
Itemid(foreign key of Itemcre)
Productid(foreign Key of Categorycrt)
Rate</pre lang="text">


I need to update the Pricefix table...please help me with the query for updating the pricefix tabletable.....


I have a gridview for pricefix table

My aspx page
<pre lang="html"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
	            onrowcancelingedit="GridView1_RowCancelingEdit"
	            onrowdeleting="GridView1_RowDeleting" 
        onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating"
	            >
	        <columns>
	        <asp:TemplateField HeaderText="PriceId">
	        <itemtemplate>
	        <asp:Label ID="lblPriceId" runat="server" Text='<%#Eval("PriceId") %>'>'> 
	        </itemtemplate>
	        
	         <asp:TemplateField HeaderText="ItemName">
	        <itemtemplate>
	        <asp:Label ID="lblItemId" runat="server" Text='<%#Eval("Itemname") %>'>'> 
	        </itemtemplate>
	        <edititemtemplate>
	        <asp:TextBox ID="txtItemId" runat="server" Text='<%#Eval("Itemname") %>'>' >
	        </edititemtemplate>
            
	         <asp:TemplateField HeaderText="ProductCategory">
	        <itemtemplate>
	        <asp:Label ID="lblPdtId" runat="server" Text='<%#Eval("ProductCategory") %>'>'> 
	        </itemtemplate>
	        <edititemtemplate>
	        <asp:TextBox ID="txtPdtId" runat="server" Text='<%#Eval("ProductCategory") %>'>' >
	        </edititemtemplate>
	        
             <asp:TemplateField HeaderText="Rate">
	        <itemtemplate>
	        <asp:Label ID="lblRate" runat="server" Text='<%#Eval("Rate") %>'>'> 
	        </itemtemplate>
	        <edititemtemplate>
	        <asp:TextBox ID="txtRate" runat="server" Text='<%#Eval("Rate") %>'>' >
	        </edititemtemplate>
	        
	            <asp:TemplateField HeaderText="Action">
                    <itemtemplate>
                        <asp:LinkButton ID="edit" runat="server" CommandName="Edit" Text="Edit">
                        <asp:LinkButton ID="Delete" runat="server" CommandName="Delete" Text="Delete">
                    </itemtemplate>
                    <edititemtemplate>
                        <asp:LinkButton ID="Update" runat="server" CommandName="Update" Text="Update">
                        <asp:LinkButton ID="Cancel" runat="server" CommandName="Cancel" Text="cancel">
                    </edititemtemplate>
                
	        </columns>


while clicking on the edit button of the grid update and cancel link button appears for the selected row .i need to update the productcategory,itemname and rate of the pricefix table.actually in pricefix table the value stored as foreignkey value of productcategory and, itemname....actually while updating the gridview of pricefix the updated productcategory and itemname should be changed in their parent table i.e, Itemcre and Categorycrt and rate inPricefix table itself...
Posted
Updated 7-May-14 21:25pm
v6
Comments
DamithSL 8-May-14 0:57am    
which fields you want to update and which inputs you have?
Ajesh1986 8-May-14 1:20am    
Hi sir thanks for the reply.... i have updated the question...kindly check and help me...
Zukiari 8-May-14 1:07am    
Can you please explain the requirement?
Ajesh1986 8-May-14 1:20am    
Hi sir thanks for the reply.... i have updated the question...kindly check and help me...
King Fisher 8-May-14 1:54am    
not clear

In case of a foreign key relationship, you can use an OnUpdate trigger to update the dependent entries (SQL Server offers a property on the foreign key constraint for that purpose - OnUpdateCascade or something like this).
In other cases, use a Transaction: it allows you to bundle many SQL queries, and then commit all of them to the db, or in case of failure rollback all of them, thus keeping the db in a consistent state.
 
Share this answer
 

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