always the same text in a textBox in a Gridview

  • Thread starter Thread starter Andrea
  • Start date Start date
A

Andrea

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
 
.......
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
 
Back
Top