HI
I have two table in database
1-House_p (users save their product information in this table)
behcode
|
Name
|
classification
|
Id
|
1111
|
Sara home
|
home
|
1
|
1111
|
Pink
|
Furniture
|
2
|
1111
|
Yellow
|
Furniture
|
3
|
4444
|
skirt
|
Cloth
|
4
|
2-House_classification(save their product classification here related to classification column's in above table)
Id
|
Name
|
behcode
|
1
|
Home
|
1111
|
2
|
Furniture
|
1111
|
3
|
Scarf
|
2222
|
4
|
Cloth
|
4444
|
|
|
|
and I have 2 gridview Product.aspx page
1-ClassGridView(that bind data from House_classification table)
2-ProductGridView (that bind data From House_p Table)
in ClassGridView I use onrowupdating attribute that users can Edit Name column from House_classification table
EX:
I want edit Furniture (Name from House_classification) I click on Edit Text(from classgridview) and Edit text
i.e I change Furniture to Instrument and after that I click on UPDATE Text from classgridview so it edit and change House_classification table like below
Id
|
Name
|
behcode
|
1
|
Home
|
1111
|
2
|
Instrument
|
1111
|
3
|
Scarf
|
2222
|
4
|
Cloth
|
4444
|
|
|
|
Now I want when I Edit name of House_classification table in same time it edit Classification Column from House_p table as you see in House_p table in two row contain Furniture
I want when I edit Furniture from House_classification Table it edit that in House_p table so I wrote below SP
ALTER procedure [dbo].[classmanagerup]
@ID varchar(20),
@Classification nvarchar(50),
@Behcode NVARCHAR(10)
as
begin
declare @DummyClasification varchar(50)
set @DummyClasification = (select Name from House_classification where ID = @ID and BehCode=@Behcode)
update House_p set Classification=@Classification
where Classification=@DummyClasification and BehCode=@Behcode
update House_classification set Name=@Classification
where ID=@ID
select ID, Name,Totalproduct
from House_classification
where BehCode=@Behcode
end
BehinCOde
protected void UpdateCustomer(object sender, GridViewUpdateEventArgs e)
{
string CustomerID = ((Label)GridView1.Rows[e.RowIndex].FindControl("lblCustomerID")).Text;
string Name = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtContactName")).Text;
SqlCommand cmd = new SqlCommand("classmanagerup", _cn);
cmd.CommandType = CommandType.StoredProcedure;
string data = Server.UrlDecode(Request.QueryString["BehCode"]);
cmd.Parameters.Add("@BehCode", data);
cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = CustomerID;
cmd.Parameters.Add("@Classification", SqlDbType.VarChar).Value = Name;
ClassGridView.EditIndex = -1;
ClassGridView.DataSource = GetData(cmd);
ClassGridView.DataBind();
BindData();
BindData1();
}
Now problem is that when I want Edit text it Update House_classification but it didn't Update House_p TAble I mean in House_p table Classification column is Furniture I want it change to Instrument Like HousE_classification Tbale
Best Regards