always the same text in a textBox in a Gridview

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
 
A

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top