Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Text from TextBox in DataList

Reply
Thread Tools

Text from TextBox in DataList

 
 
etam
Guest
Posts: n/a
 
      05-30-2007
Hi,

i have a DataList with a TextBox added by me:

<aspataList 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>
</aspataList>

How can I get text from this TextBox?

Thanks in advance,
Etam.

 
Reply With Quote
 
 
 
 
Andy
Guest
Posts: n/a
 
      05-30-2007
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"





 
Reply With Quote
 
 
 
 
etam
Guest
Posts: n/a
 
      05-30-2007
On 30 Maj, 20:55, "Eliyahu Goldin"
<(E-Mail Removed)> wrote:
> 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?

 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      05-30-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi,
>
> i have a DataList with a TextBox added by me:
>
> <aspataList 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>
> </aspataList>
>
> How can I get text from this TextBox?
>
> Thanks in advance,
> Etam.
>



 
Reply With Quote
 
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
Posts: n/a
 
      05-30-2007
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:
>
> <aspataList 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>
> </aspataList>
>
> How can I get text from this TextBox?
>
> Thanks in advance,
> Etam.
>
>

 
Reply With Quote
 
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
Posts: n/a
 
      05-30-2007
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:
> >
> > <aspataList 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>
> > </aspataList>
> >
> > How can I get text from this TextBox?
> >
> > Thanks in advance,
> > Etam.
> >
> >

 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      05-30-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> On 30 Maj, 20:55, "Eliyahu Goldin"
> <(E-Mail Removed)> wrote:
> > 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?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting TextBox.Text from within a Datalist BisMan ASP .Net 0 01-19-2008 06:07 PM
Extracting TextBox.Text from within a Datalist BisMan ASP .Net 1 01-19-2008 03:17 AM
Textbox, Input (text) on turbotax... anyone know which 3rd party textbox this is??? pld888@gmail.com ASP .Net 3 02-23-2007 08:51 PM
cannot get the text in textbox in datalist,what can i do ? mintboy ASP .Net 0 01-24-2006 05:07 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM



Advertisments