473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

Jun 27 '08 #1
1 1912
On 14 Mag, 14:11, Andrea <andrea.cicche...@diconet.itwrote:
>.......
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

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Gidi | last post by:
Hi, For the last week, i'm looking for a way to make a TextBox always write in English (No matter what the OS default language is). i asked here few times but the answers i got didn't help me. i...
2
by: VB Programmer | last post by:
I have a gridview control with several data fields. When the user clicks 'edit' for the row I want the user to be able to edit a particular text field. Under that 'edit' textbox is a button. ...
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
0
by: LiamLiamLiam | last post by:
G'day all. I having a problem with my formview. I'll ty to explain my situation as best as i can. I have a page with a search field at the top which is just a simple asp:textbox. Below that i...
1
by: savajx1 | last post by:
I need to dynamically create a set of bound fields contained in a GridView control. I also have a single static CommandField that I can declare in the Columns <tagof the GridView control. I have...
0
by: jimbob91577 | last post by:
I have a Gridview that I am dynamically adding template columns to which contain text boxes in their "Item Data" field. After adding the columns to the gridview in my Page_Load event, the page binds...
2
by: Dinu | last post by:
Hi how to get text of a control in itemtemplate of gridview and how can we access and set it properties dynamycally?? Thanks
4
by: pablorp80 | last post by:
Hello, Here is what I need: I need the focus and the cursor set to a textbox named txtGT, every time no matter if it is the first page load or whether it is a postback. Here is the problem: I...
1
by: dan | last post by:
Hi, How do I make sure that RequiredFieldValidator attached to a textbox column of a gridview is displayed on the right side of the field and not underneath? This is in edit mode of a gridview?...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.