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

productid(primary key)

Itemid(primary key)
  </pre lang="text">
<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"
        onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating"
	        <asp:TemplateField HeaderText="PriceId">
	        <asp:Label ID="lblPriceId" runat="server" Text='<%#Eval("PriceId") %>'>'> 
	         <asp:TemplateField HeaderText="ItemName">
	        <asp:Label ID="lblItemId" runat="server" Text='<%#Eval("Itemname") %>'>'> 
	        <asp:TextBox ID="txtItemId" runat="server" Text='<%#Eval("Itemname") %>'>' >
	         <asp:TemplateField HeaderText="ProductCategory">
	        <asp:Label ID="lblPdtId" runat="server" Text='<%#Eval("ProductCategory") %>'>'> 
	        <asp:TextBox ID="txtPdtId" runat="server" Text='<%#Eval("ProductCategory") %>'>' >
             <asp:TemplateField HeaderText="Rate">
	        <asp:Label ID="lblRate" runat="server" Text='<%#Eval("Rate") %>'>'> 
	        <asp:TextBox ID="txtRate" runat="server" Text='<%#Eval("Rate") %>'>' >
	            <asp:TemplateField HeaderText="Action">
                        <asp:LinkButton ID="edit" runat="server" CommandName="Edit" Text="Edit">
                        <asp:LinkButton ID="Delete" runat="server" CommandName="Delete" Text="Delete">
                        <asp:LinkButton ID="Update" runat="server" CommandName="Update" Text="Update">
                        <asp:LinkButton ID="Cancel" runat="server" CommandName="Cancel" Text="cancel">

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...
Updated 7-May-14 22:25pm
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