Datagrid TemplateColumns: EditItem FindControl not finding submitted textbox values?

Datagrid TemplateColumns: EditItem FindControl not finding submitted textbox values?

Post by Jeff » Mon, 22 Oct 2001 02:55:01



I'm confused by what the current API is for Accessing the

All the documentation and tutorial articles say to do this:

private void DataGrid1_Update(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
    DataRow dr = dataSetInvoices1.Tables["Invoices"].NewRow();
    TextBox box1 =
(TextBox)e.Item.Cells[2].FindControl("TextBoxInvoiceNumber");
    dr["invoice_number"] = box1.Text;
    TextBox box2 =
(TextBox)e.Item.Cells[2].FindControl("TextBoxInvoiceDate");
    dr["invoice_date"] = DateTime.Parse(box2.Text);
    dataSetInvoices1.Tables["Invoices"].Rows[e.Item.ItemIndex].Delete();
    dataSetInvoices1.Tables["Invoices"].Rows.Add(dr);
    DataGrid1.DataBind();
    Session["Invoice"] = dataSetInvoices1;

Quote:}

But the found controls only contain the value of the Textboxes as delivered
to the client, not the newly typed values in the "EditItem" Textboxes.

What am I missing here? Is there a pre-step to get the datagrid to accept
the user's text and other control input, or do I need a different API than
e.Item.Cells[].FindControl("")?

 
 
 

Datagrid TemplateColumns: EditItem FindControl not finding submitted textbox values?

Post by Jeff » Mon, 22 Oct 2001 03:23:59


BTW, an early answer from John Grinner (3/14/2001) addresses a different
problem:

Quote:> You have to make sure you are not calling DataBind BEFORE your
> UpdateCommand.  In my case, I had a DataBind inside the
> ItemCommand routine, and that was wiping out the values of the
> e.Item.FindControl.

I've tried it without the trailing .Databind() (and without any dataBinds at
all, save page_Load), and that isn't it...
Quote:>     dataSetInvoices1.Tables["Invoices"].Rows.Add(dr);
>     DataGrid1.DataBind();


 
 
 

1. Datagrid TemplateColumns: EditItem FindControl not finding submitted textbox values?

I'm confused by what the current API is for Accessing the

All the documentation and tutorial articles say to do this:

private void DataGrid1_Update(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
    DataRow dr = dataSetInvoices1.Tables["Invoices"].NewRow();
    TextBox box1 =
(TextBox)e.Item.Cells[2].FindControl("TextBoxInvoiceNumber");
    dr["invoice_number"] = box1.Text;
    TextBox box2 =
(TextBox)e.Item.Cells[2].FindControl("TextBoxInvoiceDate");
    dr["invoice_date"] = DateTime.Parse(box2.Text);
    dataSetInvoices1.Tables["Invoices"].Rows[e.Item.ItemIndex].Delete();
    dataSetInvoices1.Tables["Invoices"].Rows.Add(dr);
    DataGrid1.DataBind();
    Session["Invoice"] = dataSetInvoices1;

But the found controls only contain the value of the Textboxes as delivered
to the client, not the newly typed values in the "EditItem" Textboxes.

What am I missing here? Is there a pre-step to get the datagrid to accept
the user's text and other control input, or do I need a different API than
e.Item.Cells[].FindControl("")?

2. Fly Harder CD32 codes

3. Using FindControl to find a TextBox in a datagrid (using a button)

4. 500CS resetting my modem 1/min

5. I can't find the value of DataGrid's edit textbox

6. wallpaper

7. Textbox from DataGrid gives old values and not updated ones

8. Tandy 2500 SX/20 - Memory Upgrade?

9. Not able to get value changed in textbox in datagrid

10. Unable to use FindControl to find a RadioButton in a DataGrid

11. Not able to get value from the textbox in datagrid

12. After submit, how can I clear all textbox values in a FORM ?

13. submit a form to a variety of pages acording to a textbox value