Pregunta

I trying get some programmatically inserted textboxes (inserted into a gridview) to do a textChange partial update. It is sort of working but it does not automatically calls textEntered() method after I typed some text in these textboxes. I got a clue that I might need to use AJAX and things like updatepanels but I just don't fully understand how they will work in the context of what I am trying to do.

protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (!e.Row.Cells[4].Text.Equals(" ") && firstTime == false)
        {
            TextBox tb = new TextBox();
            tb.Text = e.Row.Cells[4].Text;

            tb.TextChanged += new EventHandler(textEntered);

            textBoxArray.Add(tb);

            int length = textBoxArray.Count - 1;
            tb = (TextBox)textBoxArray[textBoxArray.Count - 1];

            e.Row.Cells[4].Text = null;
            e.Row.Cells[4].Controls.Add(tb);
            Cache["textBoxArray"] = textBoxArray;

        } firstTime = false;
    }


 protected void textEntered(object sender, EventArgs e)
 {
  lbl_test.Text += "test";//This line is for testing purposes
 }
¿Fue útil?

Solución

auto postback of textbox is true or false? make it true.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top