473,320 Members | 1,900 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,320 software developers and data experts.

Text from TextBox in DataList

Hi,

i have a DataList with a TextBox added by me:

<asp:DataList ID="GradeDataList" runat="server"
DataKeyField="id" DataSourceID="ProjectsObjectDataSource">
<ItemTemplate>
topic:
<asp:Label ID="topicLabel" runat="server" Text='<%#
Eval("topic") %>'></asp:Label><br />
<asp:TextBox ID="GradeTextBox" runat="server"
Text='<%# Grade(Eval("id")) %>' />
</ItemTemplate>
</asp:DataList>

How can I get text from this TextBox?

Thanks in advance,
Etam.

May 30 '07 #1
6 4372
Use the .items collection of the datalist to obtain a reference to
your textbox by name.
Once you have the reference, set the value using the textbox's .Text
property.

ie

myDatalist.items("mytexbox").Text="My new value"

May 30 '07 #2
First get to the item, then to the textbox:
TextBox myTextBox = myItem.FindControl("GradeTextBox") as TextBox;

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"etam" <od*******@gmail.comwrote in message
news:11**********************@w5g2000hsg.googlegro ups.com...
Hi,

i have a DataList with a TextBox added by me:

<asp:DataList ID="GradeDataList" runat="server"
DataKeyField="id" DataSourceID="ProjectsObjectDataSource">
<ItemTemplate>
topic:
<asp:Label ID="topicLabel" runat="server" Text='<%#
Eval("topic") %>'></asp:Label><br />
<asp:TextBox ID="GradeTextBox" runat="server"
Text='<%# Grade(Eval("id")) %>' />
</ItemTemplate>
</asp:DataList>

How can I get text from this TextBox?

Thanks in advance,
Etam.

May 30 '07 #3
On 30 Maj, 20:55, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
First get to the item, then to the textbox:
TextBox myTextBox = myItem.FindControl("GradeTextBox") as TextBox;
TextBox tb = (TextBox)GradeDataList.FindControl("GradeTextBox") ;

Then tb == null :/.

But still it is strange... Beacause My GradeDataList has many
GradeTextBoxes. Am I right?

May 30 '07 #4
Exactly. This will work for variable of any value type, including enums.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# or VB to C++/CLI
"etam" wrote:
Hi,

i have a DataList with a TextBox added by me:

<asp:DataList ID="GradeDataList" runat="server"
DataKeyField="id" DataSourceID="ProjectsObjectDataSource">
<ItemTemplate>
topic:
<asp:Label ID="topicLabel" runat="server" Text='<%#
Eval("topic") %>'></asp:Label><br />
<asp:TextBox ID="GradeTextBox" runat="server"
Text='<%# Grade(Eval("id")) %>' />
</ItemTemplate>
</asp:DataList>

How can I get text from this TextBox?

Thanks in advance,
Etam.

May 30 '07 #5
Sorry - this made it into the wrong thread...
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# or VB to C++/CLI
"David Anton" wrote:
Exactly. This will work for variable of any value type, including enums.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# or VB to C++/CLI
"etam" wrote:
Hi,

i have a DataList with a TextBox added by me:

<asp:DataList ID="GradeDataList" runat="server"
DataKeyField="id" DataSourceID="ProjectsObjectDataSource">
<ItemTemplate>
topic:
<asp:Label ID="topicLabel" runat="server" Text='<%#
Eval("topic") %>'></asp:Label><br />
<asp:TextBox ID="GradeTextBox" runat="server"
Text='<%# Grade(Eval("id")) %>' />
</ItemTemplate>
</asp:DataList>

How can I get text from this TextBox?

Thanks in advance,
Etam.
May 30 '07 #6
You need first get to the item, something like

TextBox tb = (TextBox)GradeDataList.Items[i].FindControl("GradeTextBox");
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
"etam" <od*******@gmail.comwrote in message
news:11**********************@q66g2000hsg.googlegr oups.com...
On 30 Maj, 20:55, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
First get to the item, then to the textbox:
TextBox myTextBox = myItem.FindControl("GradeTextBox") as TextBox;

TextBox tb = (TextBox)GradeDataList.FindControl("GradeTextBox") ;

Then tb == null :/.

But still it is strange... Beacause My GradeDataList has many
GradeTextBoxes. Am I right?

May 30 '07 #7

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

Similar topics

3
by: Ben R. | last post by:
I've got a repeater that's bound to a datareader and I'd like to conditionally modify the text that is being outputted. Previously, I've done this by assigning a name to attribute to the...
1
by: Stephan Bour | last post by:
I need to build a string from the content of a datalist containing a nested datagrid. This properly returns the data from the first cell in the datagrid: String first = GridItem.Cells.Text; ...
0
by: mahsa | last post by:
Hi I want to have an editable text box in datalist but whitout forcing user to click edit or add button to see the text bo I use textbox in my datalist but its not editable why ...
4
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 ...
0
by: mintboy | last post by:
hello thank U for take a look this Message ! /////////////////c# code file private void DataListClass_UpdateCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e) {...
0
by: srinivasc | last post by:
in my project, i want to update or delete a row in the datalist according to specific field so that it will effect the database. but i have trouble while trying to get the values in the textboxes of...
1
by: =?Utf-8?B?S2V2aW4=?= | last post by:
Hi! I have a DataList that bind in the first page load (not postback). The datalist has two textbox that can be edited by the user. When I press the Save button (ImageButton) and I watch the...
1
by: =?Utf-8?B?TmVpbCBTdGV2ZW50b24=?= | last post by:
Hi All, I have a datalist that repeats a list of products and has a textbox called txtQty which you can change. I would like to put a plus and minus image next to this textbox that when you...
1
by: BisMan | last post by:
I have a datalist called datalist2 I want to get the text from a textbox called textbox1 which is in the ItemTemplate of the datalist. In the past I have gotten information out of the create...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.