Home > Net >  To obtain the GridView is selected in the content of cells, cell content is there but why get value
To obtain the GridView is selected in the content of cells, cell content is there but why get value

Time:11-24

Just want to write to the GridView editing events need access to current data line to update the database
Database is a content but with breakpoints to say by the time the step to obtain the value of the empty
 
Protected void GridView1_RowEditing (object sender, GridViewEditEventArgs e)
{
GridView1. EditIndex=e.N ewEditIndex;
ShowMessage ();
}

Protected void GridView1_RowCancelingEdit (object sender, GridViewCancelEditEventArgs e)
{
GridView1. EditIndex=1;
ShowMessage ();
}

Protected void GridView1_RowUpdating (object sender, GridViewUpdateEventArgs e)
{
String cc=GridView1. Rows [" e.R owIndex]. Cells [1]. The Text. The Trim ();
Model. The Message editmess=MessageBLL. GetModel (int. Parse (cc));

Editmess. Contents=GridView1. Rows [" e.R owIndex]. Cells [3]. The Text;

MessageBLL. Update (editmess);
ShowMessage ();
}

Is in the code above cc value is empty but the GridView that a column is really have a value in the
Please tell passing bosses
Thank you

CodePudding user response:

Refer to Microsoft's official in the sample code,
https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.gridview.rowupdating? Redirectedfrom=MSDN& View=netframework 4.8
 
Protected void TaskGridView_RowUpdating (object sender, GridViewUpdateEventArgs e)
{
//Retrieve the table from the session object.
DataTable dt=(DataTable) Session [" TaskTable "].

//Update the values.
GridViewRow row=TaskGridView. Rows [" e.R owIndex];
Dt. Rows [row. DataItemIndex] (" Id ")=((TextBox) (row. Cells [1]. The Controls [0])). The Text;
Dt. Rows [row. DataItemIndex] [" Description "]=((TextBox) (row) Cells. [2] Controls [0])). The Text;
Dt. Rows [row. DataItemIndex] [" IsComplete "]=((CheckBox) (row) Cells [3]. The Controls [0])). Checked;

//Reset the edit index.
TaskGridView. EditIndex=1;

//to Bind data to the GridView control.
BindData ();
}
  • Related