OK, never mind my last post. It was easy enough to refer to the table the
repeater is bound to, but I made a big, incorrect assumption in that post.
In my last post I thought I was successfully getting values from the
textboxes in my repeater. It turns out I am not and I can't see what I'm
doing wrong. I've had this problem before and just ended up taking a
different route to avoid it. Now I REALLY need to figure out what I'm doing
wrong.
This is for a configurable web survey form that is driven by SQL server
tables.
The repeater is coded like this:
<asp:repeater id=rptQuestions runat="server" DataSource="<%# DsQuestions1
%>" DataMember="questions">
<ItemTemplate>
<b>
<%#Convert.ToString(DataBinder.Eval(Container.Data Item, "qNum"))%>
. </b></td>
<%# DataBinder.eval(Container.Dataitem, "question") %>
</td>
<br>
<asp:TextBox ID="ans" Runat="server" />
</ItemTemplate>
<HeaderTemplate>
<b>Please answer as concisely as possible </b>
<br>
<br>
</HeaderTemplate>
<FooterTemplate>
</FooterTemplate>
<SeparatorTemplate>
<br />
<hr>
<br />
</SeparatorTemplate>
</asp:repeater>
-----------------------------------
It renders as I would expect using the values from the database. I also have
a "Submit" button. This is the click event:
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Dim strAns As String, i As Int16, dtQs As DataTable
Dim aAns(rptQuestions.Items.Count - 1, 2) As String
dtQs = DsQuestions1.Tables("questions")
For i = 0 To rptQuestions.Items.Count - 1
Dim currentTextBox As TextBox _
= CType(rptQuestions.Items(i).FindControl("Ans"),
WebControls.TextBox)
'load up an array with answers and corresponding question IDs
aAns(i, 0) = currentTextBox.Text
aAns(i, 1) = Convert.ToString(dtQs.Rows(i)("qID"))
Next
End Sub
------------------------------------
So when I look at the values in my array, the values from the datatable (the
"qID" value) is being correctly assigned. My problem is the
currentTextBox.text is always = "" even when there is text in the box. Can
anyone tell me why I'm not getting the entered values? Please?
Thanks!
Matt 1 3796
FYI - the problem was I was not putting the repeater.databind inside a If
Not IsPostBack condition. Hope that helps if anyone eles hits this issue.
Matt
MattB wrote: OK, never mind my last post. It was easy enough to refer to the table the repeater is bound to, but I made a big, incorrect assumption in that post.
In my last post I thought I was successfully getting values from the textboxes in my repeater. It turns out I am not and I can't see what I'm doing wrong. I've had this problem before and just ended up taking a different route to avoid it. Now I REALLY need to figure out what I'm doing wrong.
This is for a configurable web survey form that is driven by SQL server tables.
The repeater is coded like this:
<asp:repeater id=rptQuestions runat="server" DataSource="<%# DsQuestions1 %>" DataMember="questions"> <ItemTemplate> <b> <%#Convert.ToString(DataBinder.Eval(Container.Data Item, "qNum"))%> . </b></td> <%# DataBinder.eval(Container.Dataitem, "question") %> </td> <br> <asp:TextBox ID="ans" Runat="server" /> </ItemTemplate> <HeaderTemplate> <b>Please answer as concisely as possible </b> <br> <br> </HeaderTemplate> <FooterTemplate> </FooterTemplate> <SeparatorTemplate> <br /> <hr> <br /> </SeparatorTemplate> </asp:repeater> ----------------------------------- It renders as I would expect using the values from the database. I also have a "Submit" button. This is the click event:
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim strAns As String, i As Int16, dtQs As DataTable Dim aAns(rptQuestions.Items.Count - 1, 2) As String
dtQs = DsQuestions1.Tables("questions")
For i = 0 To rptQuestions.Items.Count - 1 Dim currentTextBox As TextBox _ = CType(rptQuestions.Items(i).FindControl("Ans"), WebControls.TextBox) 'load up an array with answers and corresponding question IDs aAns(i, 0) = currentTextBox.Text aAns(i, 1) = Convert.ToString(dtQs.Rows(i)("qID")) Next End Sub ------------------------------------
So when I look at the values in my array, the values from the datatable (the "qID" value) is being correctly assigned. My problem is the currentTextBox.text is always = "" even when there is text in the box. Can anyone tell me why I'm not getting the entered values? Please?
Thanks!
Matt This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: The Plankmeister |
last post by:
Hi...
I'm trying my hardest to understand fully how sessions work and how best to
use them. However, all I can find is information that doesn't tell me
anything other than that sessions store...
|
by: The Plankmeister |
last post by:
I'm sure this should work:
echo preg_replace("/(\w)(\!w)(\w)/","\\1\. \\3","this is.a test.to see. if
it. works");
It should output:
this is. a test. to see. if it. works
But it doesn't....
|
by: Wired Earp |
last post by:
I don't get it. First of all, it claims to run on a JRE. This is obviously
a fraud, it even says so when you attempt to start it: "The JAVA_HOME
variable should point to a JDK and not a JRE". I can...
|
by: The Plankmeister |
last post by:
Hi...
I'm attempting to keep everything I write compliant with xhtml 1.0 strict.
And It's very bizarre. Why on earth won't this validate:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html...
|
by: Jim Moe |
last post by:
Hello,
I am (slowly) in the process of changing a table-based layout to
CSS/div-based. One area that uses tables a lot is the main nav menu. I
have discovered that tables have advantage: all...
|
by: Henry Rollins |
last post by:
This is driving me nuts.
I have created a Class Assembly in .NET C# which is to be used by
traditional ASP pages. I registered it just fine with the regASM command
and it work - about 2/3 of...
|
by: Cliff Williams |
last post by:
How are people managing multiple, interdependent projects in the same
solution? If I have to rebuild my solution file one more time, I think
my head is going to spin around and pop off.
I've...
|
by: Toby Mathews |
last post by:
Hi there,
I have a problem with a C# AP.NET app. running on my local machine,
Sporadically (but more and more frequently) I get the above error message
when code running on my laptop trys to...
|
by: RWC |
last post by:
Hi Folks,
I have a windows 2000 server installation, IIS is running and the ASP.NET
1.1 SDK has been installed. I'm reading a book on ASP.NET and the lessons
call for the first line to read <%@...
|
by: darrel |
last post by:
I'm using some validators for a form.
I'm noticing that it writes the text out to the browser as a SPAN with it's
visibility set to none. The problem is that it still takes up space, so I
have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |