DataGrid - TemplateColumn

DataGrid - TemplateColumn

Post by Adrian SALANT » Wed, 16 Oct 2002 23:29:52



Hi,

I have the following aspx fragment:

<asp:DataGrid ID="grid" runat=server
AutoGenerateColumns=False>
        <columns>
                <asp:TemplateColumn HeaderText="First
Name">
                        <ItemTemplate>
                                <asp:Label ID="lblLogin"
Visible="True" Text='<%# Server.HtmlEncode (DataBinder.Eval
(Container.DataItem, "firstname").ToString())%>'
Runat=server />
                        </ItemTemplate>
                </asp:TemplateColumn>
        </columns>
</asp:DataGrid>

I want to dinamically generate more asp:TemplateColumn-s
(like the one that I have) from the codebehind page (c#).

Thanks,
Adi

 
 
 

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. PageFile size? Re: Peter Norton's 5% performance increase

3. Datagrid TemplateColumn and Select list

4. Gotta tell people how happy I am...

5. DataGrid templateColumn

6. Can Weblink support relative URL?

7. DataGrid TemplateColumns

8. Personal Internet Appliance

9. Using IF statement in DataGrid TemplateColumn

10. how to get access to a checkbox in a datagrid templatecolumn

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

12. TemplateColumn databinding in DataGrid

13. Can't get SelectedItemStyle to work with DataGrid's TemplateColumn setups.