Not updated Textbox value inside a datalist editItemTemplate

Discussion in 'ASP .Net Web Controls' started by etantonio@gmail.com, Sep 27, 2005.

  1. Guest

    Good Morning,
    I still havent solved my problem with a textbox inside an
    editItemTemplate
    of a datalist,
    in fact now it is filled with the word "CIAOOOOOO" , if a runtime in
    the
    form I put a different word
    like "PIZZAAAA" this new word is not available in the Update_Command
    following :


    void Update_Command(Object sender, DataListCommandEventArgs e)
    {
    String sNomeCampo =
    ((TextBox)e.Item.FindControl("NomeCampo")).Text;
    }

    where instead I've again sNomeCampo = "PIZZA" .
    I need help, this problem is stopping my job, many thanks

    Antonio D'Ottavio
    www.etantonio.it/en

    Here's the code inside HTML:


    <ASP:DataList id="MyDataCampi" runat="server"
    HorizontalAlign="Center"
    RepeatDirection="Horizontal" RepeatColumns="1"
    OnEditCommand="Edit_Command"
    OnUpdateCommand="Update_Command"
    OnCancelCommand="Cancel_Command" OnItemDataBound="BindComboes"
    >


    <ItemTemplate>
    <tr style="background-color:CCFF99">
    <td width=10% align="center">
    <asp:LinkButton id="EditButton" Text="Edit"
    CommandName="Edit" runat="server"/>
    <input id="HiddenIDCampo" type="hidden"
    value='<%#DataBinder.Eval(Container.DataItem, "IDCampo") %>'
    runat="server"
    />
    </td>
    <td>
    <%#
    DataBinder.Eval(Container.DataItem,"NomeCampo")%>
    </td>
    </tr>
    </ItemTemplate>

    <EditItemTemplate>
    <asp:LinkButton id="UpdateButton" Text="Update"
    CommandName="Update" runat="server"/>
    <td>
    <asp:TextBox id="NomeCampo" text='CIAOOOOOOOOOO'
    runat="server"/>
    </td>
    </EditItemTemplate>

    </ASP:DataList>
     
    , Sep 27, 2005
    #1
    1. Advertising

  2. When are you populating your DataList?
    Is this in the Page_Load.

    Often people populate there Grids/Lists in the page load and forget that
    when the page reloads this will be populated again.

    Your page_load should look as follows

    private void Page_Load(object Sender, EventArgs e)
    {
    if(!Page.IsPostBack) //Emphasis here
    {
    BindDataList(); //This method binds the list
    }
    }

    If this is not the case, the textbox will be reloaded with its original
    value,
    and something like you described would happen

    Hope that Helps


    <> wrote in message
    news:...
    > Good Morning,
    > I still havent solved my problem with a textbox inside an
    > editItemTemplate
    > of a datalist,
    > in fact now it is filled with the word "CIAOOOOOO" , if a runtime in
    > the
    > form I put a different word
    > like "PIZZAAAA" this new word is not available in the Update_Command
    > following :
    >
    >
    > void Update_Command(Object sender, DataListCommandEventArgs e)
    > {
    > String sNomeCampo =
    > ((TextBox)e.Item.FindControl("NomeCampo")).Text;
    > }
    >
    > where instead I've again sNomeCampo = "PIZZA" .
    > I need help, this problem is stopping my job, many thanks
    >
    > Antonio D'Ottavio
    > www.etantonio.it/en
    >
    > Here's the code inside HTML:
    >
    >
    > <ASP:DataList id="MyDataCampi" runat="server"
    > HorizontalAlign="Center"
    > RepeatDirection="Horizontal" RepeatColumns="1"
    > OnEditCommand="Edit_Command"
    > OnUpdateCommand="Update_Command"
    > OnCancelCommand="Cancel_Command" OnItemDataBound="BindComboes"
    > >

    >
    > <ItemTemplate>
    > <tr style="background-color:CCFF99">
    > <td width=10% align="center">
    > <asp:LinkButton id="EditButton" Text="Edit"
    > CommandName="Edit" runat="server"/>
    > <input id="HiddenIDCampo" type="hidden"
    > value='<%#DataBinder.Eval(Container.DataItem, "IDCampo") %>'
    > runat="server"
    > />
    > </td>
    > <td>
    > <%#
    > DataBinder.Eval(Container.DataItem,"NomeCampo")%>
    > </td>
    > </tr>
    > </ItemTemplate>
    >
    > <EditItemTemplate>
    > <asp:LinkButton id="UpdateButton" Text="Update"
    > CommandName="Update" runat="server"/>
    > <td>
    > <asp:TextBox id="NomeCampo" text='CIAOOOOOOOOOO'
    > runat="server"/>
    > </td>
    > </EditItemTemplate>
    >
    > </ASP:DataList>
    >
     
    Grant Merwitz, Sep 27, 2005
    #2
    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. Luis Esteban Valencia
    Replies:
    1
    Views:
    506
    John Saunders
    Jan 6, 2005
  2. Replies:
    1
    Views:
    1,804
    Grant Merwitz
    Sep 27, 2005
  3. =?Utf-8?B?RGFuIFNpa29yc2t5?=

    HOWTO: Detect FormView EditItemTemplate TextBox Value Changed

    =?Utf-8?B?RGFuIFNpa29yc2t5?=, Oct 4, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    703
    =?Utf-8?B?RGFuIFNpa29yc2t5?=
    Oct 4, 2006
  4. James
    Replies:
    1
    Views:
    850
    James
    Oct 6, 2006
  5. Hillbilly
    Replies:
    2
    Views:
    380
    bruce barker
    Sep 2, 2008
Loading...

Share This Page