Update Anomaly in DataGrid Control

Discussion in 'ASP .Net Web Controls' started by Mo Saghir, Apr 24, 2004.

  1. Mo Saghir

    Mo Saghir Guest

    I have a problem where I am trying to update a DataGrid command in place
    pretty much as outlined in the various samples in MSDN:

    private void InitialGrid1_UpdateCommand(object source,
    System.Web.UI.WebControls.DataGridCommandEventArgs e)

    {

    TextBox txtID = (TextBox)e.Item.Cells[1].Controls[0];

    TextBox txtName = (TextBox)e.Item.Cells[2].Controls[0];

    Label1.Text = txtID.Text + "-" + txtName.Text + "-";

    InitialGrid1.EditItemIndex = -1;

    BindData();

    }

    Whenever I try to access the TextBox.Text field, I get blank if the value
    was updated by the user. However, if the value is left untouched then it is
    successfully propagated to TextBox.Text field. I've been trying to debug
    this for a while now but I am reaching a dead end. The MSDN samples don't
    mention any additional details that may pertain to this situation.
    Moreover, the data binding is done via:

    ....

    MyConnection.Open();

    SqlDataAdapter myCommand = new SqlDataAdapter("select * from UserTable",
    MyConnection);



    DataSet ds = new DataSet();

    myCommand.Fill(ds, "UserTable");

    InitialGrid1.DataSource = ds;


    InitialGrid1.DataBind();

    MyConnection.Close();

    Any help would be appreciated as this is currenlty blocking me.
     
    Mo Saghir, Apr 24, 2004
    #1
    1. Advertising

  2. Mo Saghir wrote:
    > I have a problem where I am trying to update a DataGrid command in place
    > pretty much as outlined in the various samples in MSDN:
    > [snip]
    > Whenever I try to access the TextBox.Text field, I get blank if the value
    > was updated by the user. However, if the value is left untouched then it is
    > successfully propagated to TextBox.Text field.


    Are you only binding the data to the DataGrid when it is NOT a postback,
    or are you binding the data to the DataGrid on ALL page loads?

    It sounds like this may be the problem... for more info, see this FAQ:

    Why Your DataGrid's Updates Don't Show Up
    http://datawebcontrols.com/faqs/Editing/EditedValuesNotSaved.shtml

    Happy Programming!

    --

    Scott Mitchell

    http://www.4GuysFromRolla.com
    http://www.ASPFAQs.com
    http://www.ASPMessageboard.com

    * When you think ASP, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], Apr 26, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ash

    Cookie Anomaly

    Ash, Feb 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    451
  2. clintonG

    What's this 2.0 compilation anomaly?

    clintonG, Dec 30, 2005, in forum: ASP .Net
    Replies:
    16
    Views:
    2,119
    clintonG
    Jan 5, 2006
  3. Dan
    Replies:
    0
    Views:
    363
  4. Jiho Han
    Replies:
    0
    Views:
    349
    Jiho Han
    Oct 13, 2006
  5. Roedy Green

    Java control panel anomaly

    Roedy Green, Oct 23, 2011, in forum: Java
    Replies:
    2
    Views:
    1,232
    jan_bar
    Oct 24, 2011
Loading...

Share This Page