Results 1 to 5 of 5

Thread: UpdateCommand

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Santo Domingo,D.N., Dom. Rep.
    Posts
    707

    Talking UpdateCommand

    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?

    HTML Code:
    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();
    }

  2. #2

  3. #3
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Re: UpdateCommand

    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

    r0ach™
    Don't forget to rate the post

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: UpdateCommand

    Moved to C# forum

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Santo Domingo,D.N., Dom. Rep.
    Posts
    707

    Re: UpdateCommand

    Quote Originally Posted by RhinoBull
    This is VB6 forum - not C#. Ask admins to move it to the appropriate place.
    Sorry!
    It was a mistake.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width