StckDetailsという名前のようなテーブルを作成します
ここに画像の説明を入力します
anme sp_StckDetails1ALTERプロシージャ[dbo]。[sp_StockDetails1](
@Action varchar(20)、@ Branch_ID int = null、@ Stock_Name varchar(50)= null、@ Stock_code varchar(20)= null、@ Qty int = null、@ Purchase_Price decimal(18,0)= null、@ Sales_Price decimal(18,0)= null、@ Order_ID int = null)as BEGIN SET NOCOUNT ON; @ Action ='Update'の場合、更新を開始しますStockDetails set Qty = @ Qty、Purchase_Price = @ Purchase_Price、Sales_price = @ Sales_Price where Order_ID = @ Order_ID end End
次に、c#code is Label lbl_id = GridView2.Rows [e.RowIndex] .FindControl( "Label2")asLabelを追加します。TextBox txt1_qty = GridView2.Rows [e.RowIndex] .FindControl( "TextBox7")as TextBox; TextBox txt2_PP = GridView2.Rows [e.RowIndex] .FindControl( "TextBox8")as TextBox; TextBox txt3_sp = GridView2.Rows [e.RowIndex] .FindControl( "TextBox9")as TextBox;
SqlCommand cmd = new SqlCommand("sp_StockDetails1", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "Update");
cmd.Parameters.AddWithValue("@Order_ID", SqlDbType.Int).Value = Convert.ToInt32(lbl_id.Text);
cmd.Parameters.AddWithValue("@Qty", SqlDbType.Int).Value = Convert.ToInt32(txt1_qty.Text);
cmd.Parameters.AddWithValue("@Purchase_Price", SqlDbType.Decimal).Value = Convert.ToDecimal(txt2_PP.Text);
cmd.Parameters.AddWithValue("@Sales_Price", SqlDbType.Decimal).Value = Convert.ToDecimal(txt3_sp.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
GridView2.EditIndex = -1;
fillgrid2();
Gridviewのdesinコードはaspxコードです
'>'>'>'>'>'>'>'>'>'>........................................。........................................。........................................。
それを試してみてください