Results 1 to 4 of 4

Thread: grid + textbox + autopostback + javascript focus

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Posts
    194

    grid + textbox + autopostback + javascript focus

    I have a grid with text box,

    I change the text box to be AutoPostBack="true"

    when I change the data I have event that insert the data to the DB.

    Code:
      protected void mark_TextChanged(object sender, EventArgs e)
        {
    
            TextBox t = (TextBox)sender;
            GridViewRow grdRow = (GridViewRow)t.Parent.Parent;
      Label l = (Label)grdRow.FindControl("questionID");
    // HERE I INSERT THE DATA TO THE DB
    //TRY TO GO TO THE TEXT BOX IN THE NEXT ROW
          grdRow = new GridViewRow(grdRow.RowIndex + 1,grdRow.DataItemIndex,DataControlRowType.DataRow, DataControlRowState.Normal);          
                           l  = (Label)grdRow.FindControl("questionID"); //BREAK HERE
                           Page.ClientScript.RegisterStartupScript(this.GetType(), "aaa", "document.getElementById('" + l.ClientID + "').focus()", true);
    how can I go th the next row in the grid.

    thanks!

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: grid + textbox + autopostback + javascript focus

    Isn't that going to be super inefficiant, because every keystroke in your text box will result in a call to the db?

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: grid + textbox + autopostback + javascript focus

    Add an 'update' or 'insert' column to your grid. Let the user type into the textbox in peace and have him click the update button to perform the database transaction.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: grid + textbox + autopostback + javascript focus

    That will also take care of the 'next' row, as an update button exists for each row in the grid.

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