473,763 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

findcontrol inside a DataList returns an object but no data

hi all

i use FindControl to get a textbox, and i get a textbox object, but it's
..Text property is empty.

some background info: i have a DataList, which has a template column in it,
and in that template column i define a textbox.

<asp:TemplateCo lumn HeaderText="Qua ntity">
<ItemTemplate >
<asp:TextBox id="Quantity" runat="server" Columns="4" MaxLength="3"
Text='<%# DataBinder.Eval (Container.Data Item, "Quantity") %>' width="40px"
/>
</ItemTemplate>
</asp:TemplateCol umn>

Later on, i want to go through all the rows in the datalist (called MyList),
and do some processing based on the contents of the textboxes, which may
have been changed by the user.

For i = 0 To MyList.Items.Co unt - 1

Dim quantityTxt As TextBox = CType(MyList.It ems(i).FindCont rol("Quantity") ,
TextBox)

'do some stuff here

Next

quantityTxt.Tex t is always vbNullstring. i have tried
MyList.Items(i) .Cells(2).FindC ontrol("Quantit y") as well, which makes no
difference.

any idea why??

any help very much appreciated.

thanks

Rimu


Nov 18 '05 #1
2 1544
and no, i am not over-writing the contents of the datalist on postback...
Nov 18 '05 #2
i found an incredible amount of other postings dealing with very similar
problems, so i thought i'd better show my solution.

any page can have only 1 <form runat=server>, and if you have more than 1,
then .net will cry about it and refuse to run your page.

however, .net WILL let you have an extra <form> (without the runat=server),
but it throws all your viewstates out of whack. in my case, my second <form>
was within the main <form> block, so it's not valid HTML, even....

R

"Rimu Atkinson" <ri***@paradise .net.removenosp amthing.nz> wrote in message
news:mu******** ************@ne ws02.tsnz.net.. .
hi all

i use FindControl to get a textbox, and i get a textbox object, but it's
.Text property is empty.

some background info: i have a DataList, which has a template column in it, and in that template column i define a textbox.

<asp:TemplateCo lumn HeaderText="Qua ntity">
<ItemTemplate >
<asp:TextBox id="Quantity" runat="server" Columns="4" MaxLength="3"
Text='<%# DataBinder.Eval (Container.Data Item, "Quantity") %>' width="40px"
/>
</ItemTemplate>
</asp:TemplateCol umn>

Later on, i want to go through all the rows in the datalist (called MyList), and do some processing based on the contents of the textboxes, which may
have been changed by the user.

For i = 0 To MyList.Items.Co unt - 1

Dim quantityTxt As TextBox = CType(MyList.It ems(i).FindCont rol("Quantity") , TextBox)

'do some stuff here

Next

quantityTxt.Tex t is always vbNullstring. i have tried
MyList.Items(i) .Cells(2).FindC ontrol("Quantit y") as well, which makes no
difference.

any idea why??

any help very much appreciated.

thanks

Rimu

Nov 18 '05 #3

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

Similar topics

1
425
by: Rimu Atkinson | last post by:
hi all i use FindControl to get a textbox, and i get a textbox object, but it's ..Text property is empty. some background info: i have a DataList, which has a template column in it, and in that template column i define a textbox. <asp:TemplateColumn HeaderText="Quantity"> <ItemTemplate>
0
1035
by: ani | last post by:
I have a datalist control in my aspx page(this is paginated and everytime submits to itself). I am calling a function within my datalist that returns a html control (radio button ) in the form of the string. I also have asp server controls(labels) in the datalist. When the form is processed, I am retrieving the values of the radio buttons through Request.form. To retrieve the values of the asp server controls , I am using FindControl...
1
1722
by: Mike Speak | last post by:
On my page_load, I am populating a Datagrid through the normal manner (which works) before attempting to pick out the items in one column to use in another part of my page. This is all within page_load. Within my Datagrid I have an <ItemTemplate/> tag with a child <asp:Label/> tag. The ID on the <asp:Label/> tag is set to "lblDescription". I am using the following code to iterate over the DataGrid control and pick out the descriptions...
4
4155
by: MattB | last post by:
This is just a rephrased version of a question I posted earlier. I think I'm closer now, so it seemed worthy of a new (more specific) post. In my repeater I'm dynamically creating text boxes, so at compile time I don't know what text boxes are going to be present at run time. This is where it seems the FindControl method would be come into play. I loop through a list of control (all textboxes) names I created on page load and see if they...
8
7436
by: Adam Billmeier | last post by:
Problem: I am trying to use FindControl to grab a dropdownlist that is in the EditItemTemplate of a Datalist and then Bind it to a dataset. I also then need to put the correct values in all of the text boxes in the EditItemTemplate. I have set the EditItemIndex for the Datalist to -1, and then bound the Datalist. I then want to Bind the DropDown, and populate the values. All attempts to use FindControl on the control return "Nothing"
1
8529
by: Paul | last post by:
I have an item in the aspx part of my page: <a id="PreviousPageNav" runat="server" > <asp:Image runat=server ID="PreviousImage" ImageUrl="~/Images/Nav/previous.gif" /> </a> that I put in the header of a DataList.
2
6565
by: christof | last post by:
How to do it: My page: <asp:DataList ID="dataListRoleMembers" ...> .... <FooterTemplate> <asp:LinkButton ID="btnAddMember" runat="server" OnClick="btnAddMember_Click">Add...</asp:LinkButton> <asp:TextBox ID="txtAddMember" runat="server"></asp:TextBox>
2
2074
by: jobs | last post by:
I have two Nested repeating Datalists with different data sources. Currently the second Datalist is set to visible=false I have an oncommand button on the first, that when selected I would like to make it's sub datalist visible. I'm a bit confused about how to refrence the instance of the second datalist.
2
5925
by: Srini | last post by:
I customized the SideBarTemplate of the Wizard control and added a Label with ID Label1 to it. I want to change the Text of the label based on the current step. But the following always returns null Label L = (Label)Wizard1.FindControl( "Label1" ); As per the help file, this should return the Label. Here is the script for the template <SideBarTemplate>
0
9386
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
10145
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9822
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
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...
0
5270
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
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.