FindControl Method always returns empty string!!!!!

Discussion in 'ASP .Net Web Controls' started by steroche, Aug 25, 2005.

  1. steroche

    steroche Guest

    Hi guys - Can somebody please help me?
    I'm a novice at all thisIve run into a serious stumbling block for the
    last few hours now and its killing me!
    I have a paged/sorted Datagrid setup and it works fine except for the
    update method - i just cannot get it to work!
    Now i keep getting the error :

    Exception Details: System.NullReferenceException: Object reference not
    set to an instance of an object
    on line
    Line 486: this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][3]
    = newCaseID;

    Here is my update method:

    private void dgGarda_UpdateCommand(object source,
    System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    string newCaseID, newStationID = null;
    string newLname,newRank,newArea = null;

    TextBox tb;
    //all tb.Text vals = "" below
    tb =
    (TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditCase"));
    newCaseID = tb.Text.ToString();
    tb =
    (TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditStation"));
    newStationID = tb.Text;
    tb =
    (TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditRank"));
    newRank = tb.Text;
    tb =
    (TextBox)(dgGarda.Items[dgGarda.EditItemIndex].FindControl("txtEditArea"));
    newArea = tb.Text;

    this.dsGarda.Tables[1].Rows[e.Item.ItemIndex][3] = newCaseID;
    this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][4] = newStationID;
    this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][5] =
    newRank;this.dsGarda.Tables["Garda"].Rows[e.Item.ItemIndex][6] =
    newArea;

    this.daGarda.Update(dsGarda, "Garda");
    dgCase.EditItemIndex = -1;
    dgCase.DataBind();
    }

    When i step through the code i see that all my FindControl methods are
    returning empty strings aswell!!Anybody have any idea whats going on??I
    read somewhere i should have the datagrid.databind call in the if
    (!IsPostBack) but when i did this it didn't reload the grid when i
    clicked edit.

    Any help is greatly appreciated as i think i am going to kill my
    computer shortly if i cant fix this!!!

    Thanks,
    Steve
     
    steroche, Aug 25, 2005
    #1
    1. Advertising

  2. steroche

    steroche Guest

    Please Help Me!!! :- (
     
    steroche, Aug 25, 2005
    #2
    1. Advertising

  3. steroche

    steroche Guest

    One problem down, was rebinding old data each time i went to upload- in
    the DataGrid1_EditCommand - which is odd,didn't think that would effect
    the subsequent DataGrid1_UpdateCommand but evidently it does!
     
    steroche, Aug 25, 2005
    #3
    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. al
    Replies:
    7
    Views:
    4,138
    George
    Jun 17, 2004
  2. Hanif
    Replies:
    6
    Views:
    18,008
    Paul Lutus
    Oct 17, 2003
  3. steroche

    FindControl Method always returns empty string!!!!!

    steroche, Aug 25, 2005, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    157
    steroche
    Aug 25, 2005
  4. steroche

    FindControl Method always returns empty string!!!!!

    steroche, Aug 25, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    155
    steroche
    Aug 25, 2005
  5. Michi Henning

    document.cookie always returns empty string

    Michi Henning, Jan 15, 2007, in forum: Javascript
    Replies:
    6
    Views:
    207
    Dr J R Stockton
    Jan 18, 2007
Loading...

Share This Page