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

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:TemplateColumn HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox id="Quantity" runat="server" Columns="4" MaxLength="3"
Text='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' width="40px"
/>
</ItemTemplate>
</asp:TemplateColumn>

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.Count - 1

Dim quantityTxt As TextBox = CType(MyList.Items(i).FindControl("Quantity"),
TextBox)

'do some stuff here

Next

quantityTxt.Text is always vbNullstring. i have tried
MyList.Items(i).Cells(2).FindControl("Quantity") as well, which makes no
difference.

any idea why??

any help very much appreciated.

thanks

Rimu


Nov 18 '05 #1
2 1529
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.removenospamthing.nz> wrote in message
news:mu********************@news02.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:TemplateColumn HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox id="Quantity" runat="server" Columns="4" MaxLength="3"
Text='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' width="40px"
/>
</ItemTemplate>
</asp:TemplateColumn>

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.Count - 1

Dim quantityTxt As TextBox = CType(MyList.Items(i).FindControl("Quantity"), TextBox)

'do some stuff here

Next

quantityTxt.Text is always vbNullstring. i have tried
MyList.Items(i).Cells(2).FindControl("Quantity") 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
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...
0
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...
1
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...
4
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...
8
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...
1
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...
2
by: christof | last post by:
How to do it: My page: <asp:DataList ID="dataListRoleMembers" ...> .... <FooterTemplate> <asp:LinkButton ID="btnAddMember" runat="server"...
2
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...
2
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...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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.