473,668 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Textbox value in the edittemplate of a datalist doesn't report the changes

Good Morning,
I've a problem with a textfiled inside a datalist, in particular it's value
it is not updated with the changes,
I mean sNomeCampo has still the value coming from the dB and not that
changed by the user,
May you help me ???

Antonio D'Ottavio
www.etantonio.it/en

Here's the code :
void Update_Command( Object sender, DataListCommand EventArgs e)
{
String sNomeCampo =
((TextBox)e.Ite m.FindControl(" NomeCampo")).Te xt;
}

<ASP:DataList id="MyDataCampi " runat="server" HorizontalAlign ="Center"
RepeatDirection ="Horizontal " RepeatColumns=" 1"
OnEditCommand=" Edit_Command" OnUpdateCommand ="Update_Comman d"
OnDeleteCommand ="Delete_Comman d" OnCancelCommand ="Cancel_Comman d"
OnItemDataBound ="BindComboe s"


<ItemTemplate >
<tr style="backgrou nd-color:CCFF99">
<td width=10% align="center">
<asp:LinkButt on id="EditButton " Text="Edit"
CommandName="Ed it" runat="server"/>
<input id="HiddenIDCam po" type="hidden" value='<%#
DataBinder.Eval (Container.Data Item, "IDCampo") %>' runat="server" />
</td>
<td>
<%# DataBinder.Eval (Container.Data Item,
"NomeCampo" )%>
</td>
</tr>
</ItemTemplate>

<EditItemTempla te>
<asp:LinkButt on id="UpdateButto n"
Text="Update"
CommandName="Up date"
runat="server"/>

<td>
<asp:TextBox id="NomeCampo"
Text='<%# DataBinder.Eval (Container.Data Item,
"NomeCampo" ) %>'
runat="server"/>
</td>
</EditItemTemplat e>

</ASP:DataList>
Nov 19 '05 #1
2 1717
I am not sure where you are going with this, so let's just cover the basics
of data CRUD in ADO.NET with ASP.NET and see if it helps.

1. Get data
a) Set up command, connection, dataAdapter and DataSet objects
b) (optional, but recommended) - map the generic tables in the
DataAdapter to more useful names
c) Use Fill() on the DataAdapter to fill the data set
2. Fill the container - in your case, a DataList
3. User updates data
4. User submits form
5. Call Update on the DataAdapter to update data
6. Rebind the container with current data

Try this:
http://www.dotnetjohn.com/articles.aspx?articleid=17

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** ************
Think Outside the Box!
*************** ************
"Antonio D'Ottavio" wrote:
Good Morning,
I've a problem with a textfiled inside a datalist, in particular it's value
it is not updated with the changes,
I mean sNomeCampo has still the value coming from the dB and not that
changed by the user,
May you help me ???

Antonio D'Ottavio
www.etantonio.it/en

Here's the code :
void Update_Command( Object sender, DataListCommand EventArgs e)
{
String sNomeCampo =
((TextBox)e.Ite m.FindControl(" NomeCampo")).Te xt;
}

<ASP:DataList id="MyDataCampi " runat="server" HorizontalAlign ="Center"
RepeatDirection ="Horizontal " RepeatColumns=" 1"
OnEditCommand=" Edit_Command" OnUpdateCommand ="Update_Comman d"
OnDeleteCommand ="Delete_Comman d" OnCancelCommand ="Cancel_Comman d"
OnItemDataBound ="BindComboe s"
>


<ItemTemplate >
<tr style="backgrou nd-color:CCFF99">
<td width=10% align="center">
<asp:LinkButt on id="EditButton " Text="Edit"
CommandName="Ed it" runat="server"/>
<input id="HiddenIDCam po" type="hidden" value='<%#
DataBinder.Eval (Container.Data Item, "IDCampo") %>' runat="server" />
</td>
<td>
<%# DataBinder.Eval (Container.Data Item,
"NomeCampo" )%>
</td>
</tr>
</ItemTemplate>

<EditItemTempla te>
<asp:LinkButt on id="UpdateButto n"
Text="Update"
CommandName="Up date"
runat="server"/>

<td>
<asp:TextBox id="NomeCampo"
Text='<%# DataBinder.Eval (Container.Data Item,
"NomeCampo" ) %>'
runat="server"/>
</td>
</EditItemTemplat e>

</ASP:DataList>

Nov 19 '05 #2
Hi Antonio,

The most possible reason to cause this kind problem is that the value in the
textbox is overwritten by value from DB (The datalist’s data source is
rebound.) before conducting update.

So make sure only binding data source when is not pastback:

if (!IsPostback)
{
Datalist.DataSo urce = datasource_Obje ct;
Datalist..DataB ind();
}

HTH

Elton Wang

"Antonio D'Ottavio" wrote:
Good Morning,
I've a problem with a textfiled inside a datalist, in particular it's value
it is not updated with the changes,
I mean sNomeCampo has still the value coming from the dB and not that
changed by the user,
May you help me ???

Antonio D'Ottavio
www.etantonio.it/en

Here's the code :
void Update_Command( Object sender, DataListCommand EventArgs e)
{
String sNomeCampo =
((TextBox)e.Ite m.FindControl(" NomeCampo")).Te xt;
}

<ASP:DataList id="MyDataCampi " runat="server" HorizontalAlign ="Center"
RepeatDirection ="Horizontal " RepeatColumns=" 1"
OnEditCommand=" Edit_Command" OnUpdateCommand ="Update_Comman d"
OnDeleteCommand ="Delete_Comman d" OnCancelCommand ="Cancel_Comman d"
OnItemDataBound ="BindComboe s"
>


<ItemTemplate >
<tr style="backgrou nd-color:CCFF99">
<td width=10% align="center">
<asp:LinkButt on id="EditButton " Text="Edit"
CommandName="Ed it" runat="server"/>
<input id="HiddenIDCam po" type="hidden" value='<%#
DataBinder.Eval (Container.Data Item, "IDCampo") %>' runat="server" />
</td>
<td>
<%# DataBinder.Eval (Container.Data Item,
"NomeCampo" )%>
</td>
</tr>
</ItemTemplate>

<EditItemTempla te>
<asp:LinkButt on id="UpdateButto n"
Text="Update"
CommandName="Up date"
runat="server"/>

<td>
<asp:TextBox id="NomeCampo"
Text='<%# DataBinder.Eval (Container.Data Item,
"NomeCampo" ) %>'
runat="server"/>
</td>
</EditItemTemplat e>

</ASP:DataList>

Nov 19 '05 #3

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

Similar topics

0
332
by: Antonio D'Ottavio | last post by:
Good Morning, I've a problem with a textfiled inside a datalist, in particular it's value it is not updated with the changes, I mean sNomeCampo has still the value coming from the dB and not that changed by the user, May you help me ??? Antonio D'Ottavio www.etantonio.it/en
1
4553
by: etantonio | last post by:
Good Morning, I still havent solved my problem with a textbox inside an editItemTemplate of a datalist, in fact now it is filled with the word "CIAOOOOOO" , if a runtime in the form I put a different word like "PIZZAAAA" this new word is not available in the Update_Command following :
0
1020
by: Gönen EREN | last post by:
I want to populate a datalist in edittemplate the probleme: i get an error while accesing the datagrid public void DataListEdit(Object src, DataListCommandEventArgs e ) { DataList.EditItemIndex=e.Item.ItemIndex;
0
1218
by: Gaurav Gargate | last post by:
Hi Group, I am creating a ASP.NET (C#) project. I am creating a datalist with some dynamically generated text boxes in the edit template. I have the datalist control on the form. The text box is written on the form at run time. Using Response.Write() on the EditTemplate I write the HTML code required for the text box along with the data and the ID for the text box.
2
5509
by: donnet | last post by:
Inside my .aspx file, I have a textbox populated with data from a dataset like this: <asp:TextBox text='<%# DataBinder.Eval(Container.DataItem, "Comment")%>' id="CommentText" runat="server" TextMode="MultiLine"></asp:TextBox> </ItemTemplate> </asp:datalist> <asp:button id="EditCommentButton" Text="Edit Comment" Runat="server"></asp:button
4
8754
by: bwalke | last post by:
I am developing a web form which is going to be used for manufacturing input. The form uses a DataList which list a batch of parts that may range anywhere from 1-9 parts. The DataList contains 6 textboxes pre-fill with data (reason for using datalist) which will capture user input and changes to the textboxes. So the 6 textboxes in columns will be constant but the rows will vary representing each part. I am looking to loop through...
10
1487
by: Nathan Sokalski | last post by:
I have a DataList control with an EditTemplate. Three of the controls in this template include a Calendar, a Button with CommandName="update", and a Button with CommandName="cancel". Whenever I click one of these controls, the DataList replaces the EditTemplate with the ItemTemplate. I think this is because the method I wrote which performs the databinding is getting called, but I don't know why or where it is getting called from. It does...
0
910
by: Stanley Cheung | last post by:
Dear all, i put a datalist into a user control and then apply the itemtemplate & ediiTemplate inside, i use dgXXX.itemcommand to get the commandname from button the problem is the content of EditTemplate doesn't show up when user click the button on ItemTemplate. I done many problem with above method and no problem at all,
6
2894
by: john | last post by:
I have the following textbox setup with Text & ToolTip Bindings as follows; I'm using Visual Studio 2008 VB: <asp:TextBox ID="txtDay1" runat="server" Text='<%# Eval("Day1") %>' Width="30px" ToolTip='<%# Eval("M1") %>'></asp:TextBox>
0
8381
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8797
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7401
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5681
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4205
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2791
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.