DataGrid write to Textbox in ItemDataBound help.

Discussion in 'ASP .Net Datagrid Control' started by Jay, Jul 29, 2004.

  1. Jay

    Jay Guest

    Hopefully someone can help me with this.
    I have a datagrid that has many textboxes that when you go in are
    empty and users can enter info in them and submit.
    I now have added the ablity to save what you enter to recall it later.
    There is a Textbox called ExtPrice that uses some javascript to
    multiple quantity by Price and fill out this textbox.
    When I load from the saved file this data is not stored so I figured
    no problem I will fill it in on the DataBound however I can not get
    access to this Textbox.
    POLoad is a bool that is set to true when they load from a saved file.
    Just useing the "1" to try and write anything at this point.

    Here is the datagrid column.

    <asp:TemplateColumn HeaderText="Ext. Price">
    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
    <ItemStyle Font-Size="XX-Small" Font-Names="Arial" Font-Bold="True"
    HorizontalAlign="Right" VerticalAlign="Middle"
    BackColor="Gainsboro"></ItemStyle>
    <ItemTemplate>
    <asp:TextBox ID="ExtPrice" ReadOnly="True" TabIndex="-5"
    EnableViewState="True" Runat="server" Columns="7" />
    </ItemTemplate>
    </asp:TemplateColumn>

    Code I have tried...

    private void DataGrid_ItemDataBound(object s, DataGridItemEventArgs e)
    {
    ListItemType itemType = e.Item.ItemType;
    if (POLoad && itemType != ListItemType.Header)
    {
    TextBox Edit = (TextBox)e.Item.FindControl("ExtPrice");
    Edit.Text = "1";
    }
    }


    Next Idea...

    private void DataGrid_ItemDataBound(object s, DataGridItemEventArgs e)
    {
    ListItemType itemType = e.Item.ItemType;
    if (POLoad && itemType != ListItemType.Header)
    {

    e.Item.Cells[6].Controls.Remove((TextBox)e.Item.FindControl("ExtPrice"));

    TextBox ExtPrice = new TextBox(); ExtPrice.Text = "1";

    e.Item.Cells[6].Controls.Add(ExtPrice);

    }
    }


    I can get a 1 to appear in the cells if I do this....

    private void DataGrid_ItemDataBound(object s, DataGridItemEventArgs e)
    {
    ListItemType itemType = e.Item.ItemType;

    if (POLoad && itemType != ListItemType.Header)
    {

    e.Item.Cells[6].Text = "1";

    }
    }

    But I need the textbox in case people make changes to the Price and
    Quanitity...

    Any help would me very much appricated!

    Thanks
    Jay, Jul 29, 2004
    #1
    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. Tony Middleton

    Datagrid losing changes made in ItemDataBound

    Tony Middleton, Apr 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    304
    Tony Middleton
    Apr 22, 2004
  2. =?iso-8859-1?Q?Andr=E9_Almeida_Maldonado?=

    DataGrid - ItemDataBound

    =?iso-8859-1?Q?Andr=E9_Almeida_Maldonado?=, Jul 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,023
    Ken Cox [Microsoft MVP]
    Jul 7, 2004
  3. Dave

    ItemDataBound event of DataGrid

    Dave, Oct 7, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,940
    Scott Allen
    Oct 7, 2004
  4. RJN
    Replies:
    1
    Views:
    531
    Brent Humber
    Dec 24, 2006
  5. Ather Ali Shaikh

    How can I get textbox created ID in itemdatabound

    Ather Ali Shaikh, Sep 4, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    260
    Ather Ali Shaikh
    Sep 6, 2004
Loading...

Share This Page