PDA

Click to See Complete Forum and Search --> : UpdateCommand


Luis Moises Rojas
May 26th, 2006, 01:49 PM
This code is suppose to update a table, but: Why e.item.Cells[2].Text does not have any value?
What i am doing wrong?

private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{ Utilitarios oUtil=new Utilitarios();
string sqlquery="Update ENC_TIPO_RESPUESTA set chr_tipo_respuesta='" + e.Item.Cells[2].Text + "'" +
" where chr_tipo_respuesta='" + TextBox1.Text + "'";
int RowAffected=oUtil.DeleteRow(sqlquery);
if(RowAffected ==0)
{
Page.RegisterStartupScript("errs","<script language=Javascript>alert('Registro Actualizado...');</script>");
BindData();
}
else
{
Page.RegisterStartupScript("errs","<script language=Javascript>alert('No se puede actualizar Registro...');</script>");
}
DataGrid1.EditItemIndex=-1;
BindData();
}

RhinoBull
May 26th, 2006, 01:51 PM
This is VB6 forum - not C#. Ask admins to move it to the appropriate place.

r0ach
May 26th, 2006, 01:53 PM
What you're doing wrong is posting a C# question in a vb forum.

Next, how many items are in the DataGrid? Remember that it is all 0 based, so [2] will be item 3

si_the_geek
May 26th, 2006, 02:32 PM
Moved to C# forum

Luis Moises Rojas
May 26th, 2006, 03:14 PM
This is VB6 forum - not C#. Ask admins to move it to the appropriate place.

Sorry!
It was a mistake.