always the same text in a textBox in a Gridview

Discussion in 'ASP .Net' started by Andrea, May 14, 2008.

  1. Andrea

    Andrea Guest

    Hallo,
    I'll try to explain me in english.... sorry for my results.

    I'm trying to use a gridview update function. (C#) These are my first
    experiments in asp.net

    I'have this TemplateField

    <asp:TemplateField HeaderText="myTesto">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DATA")
    %>' MaxLength="6" Width="37px" CssClass="myclass"></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label1" runat="server" Text='<%# Bind("DATA")
    %>'></asp:Label> </ItemTemplate>
    </asp:TemplateField>

    and the function ...

    protected void GridView1_RowUpdating(object sender,
    GridViewUpdateEventArgs e)
    {
    string mynewTest = ((TextBox)(row.Cells[1].Controls[0])).Text;
    // I need to control this string
    if (check(mynewTesr))
    {
    //do the update
    if (myUpdateFunction())
    {
    this.GridView1.EditIndex = -1;
    //Bind data to the GridView control.
    BindData();
    }
    }
    else
    {
    this.labelTest.Text = mynewTest;
    }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    BindData();
    }
    }

    As you can see, I need to check my string before Updating it end if
    something is wrong i control with a label (labelTest).
    So in the gredview I have the value "NewYork". I change it (in the
    textbox o the TemplateField) with the value "Rome", I submit the
    update and in my label there is the always "NewYork"... and also in
    the TemplateField,
    in the "TextBox1" (we are in edit mode) there is "NewYork".

    Can you Help me

    Thanks in advance

    Andrea
    Andrea, May 14, 2008
    #1
    1. Advertising

  2. Andrea

    Andrea Guest

    On 14 Mag, 14:11, Andrea <> wrote:
    >.......
    > So in the gredview I have the value "NewYork". I change it (in the
    > textbox o the TemplateField) with the value "Rome", I submit the
    > update and in my label there is the always "NewYork"... and also in
    > the TemplateField,
    > in the "TextBox1" (we are in edit mode) there is  "NewYork".
    > Andrea



    Sorry, my fault : I forgot to put EnableViewState="False"

    Bye
    Andrea, May 14, 2008
    #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. Deryck
    Replies:
    4
    Views:
    506
    derek giroulle
    Jun 22, 2004
  2. Replies:
    3
    Views:
    735
    George Ter-Saakov
    Feb 23, 2007
  3. agb

    writing two textbox's text in one textbox

    agb, Aug 26, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    163
    Ken Cox [Microsoft MVP]
    Aug 27, 2003
  4. ErwinP
    Replies:
    1
    Views:
    721
    ErwinP
    Aug 19, 2005
  5. jobs
    Replies:
    2
    Views:
    1,567
Loading...

Share This Page