Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   always the same text in a textBox in a Gridview (http://www.velocityreviews.com/forums/t614774-always-the-same-text-in-a-textbox-in-a-gridview.html)

Andrea 05-14-2008 12:11 PM

always the same text in a textBox in a Gridview
 
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 05-14-2008 12:24 PM

Re: always the same text in a textBox in a Gridview
 
On 14 Mag, 14:11, Andrea <andrea.cicche...@diconet.it> 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



All times are GMT. The time now is 07:12 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.