So, should I think no one has a solution to this?

A

ani

I have been posting this question for the past 2 weeks and
there wasn't any response. I really don't understand why I
am not getting any responses. Does my question sound very
stupid? Anyway, here I am asking again. Someone please
please help me!!

How do I add a radiobuttonlist within a datalist
programatically.

My actual problem is with retrieving the user-input and
the form values at the same time.
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
method. But this is written in the Page_Load method, so
it returns the values of the current page before the page
gets submitted. I want the values after the page gets
submitted. How do I retrieve them.
If I use onserverclick on my button (which is a html
control with rollover capability <a href>) , the
onclick doesn't work fine for validating the html
controls. I don't have runat=server on my form tag when I
have onclick attribute on the button. I am new to
asp.net. I am not able to use both onclick and
onserverclick at the same time. Why is it so..

Please help!!



<form id="frmQuestion" method="post" >

<ASP:DataList id="Questions" ShowHeader="false"
ShowFooter="false" runat="server" >
<ItemTemplate>
<TABLE ALIGN="left" >
<td>

<asp:Label runat="server" Text='<%# DataBinder.Eval
(Container.DataItem, "MainQuestion_ID")%> '
ID="QuestionID" NAME="QuestionID">
</asp:Label>

</td>

<td>

<asp:Label runat="server" Text='<%# DataBinder.Eval
(Container.DataItem, "MainQuestion_Txt")%>'
ID="QuestionTxt" NAME="QuestionTxt">
</asp:Label>

</td>

<td >

<%# DisplayAnswers(DataBinder.Eval
(Container.DataItem, "MainQuestion_ID"),DataBinder.Eval
(Container.DataItem, "QuestionTypeID")) %>

</td>
</tr></TABLE>
</ItemTemplate>
</ASP:DataList>

<table align=right >
<tr><td>

<a id=btnForward href="#"
onMouseOut="bforward.src='images/bforward.gif';"
onMouseOver="bforward.src='images/bforward_f2.gif';"
runat=server onclick="return validate();"><IMG
SRC="images/bforward.gif" ALT="" NAME="bforward"
ID="bforward" WIDTH="78" HEIGHT="24" BORDER="0"></A>

</td></tr></table>


I would like to retrieve the question id and the answer
(user-input) at the same time on click of the button.
The
questionaire is paginated and this is the only form i am
using.

The code behind looks somewhat this way:

Sub Page_Load(ByVal Sender As Object, ByVal E As
EventArgs)


Dim oDt As DataTable
Dim oQuestion As Question ('This is the
class
in my business layer)
oQuestion = New Question

Questions.DataSource = New DataView(oDt)
Questions.DataBind()



End Sub


how do I get questionid's and user-input to
insert into the database. There can be subquestions
 
S

S. Justin Gengo

Ani,

You need to set up your controls to use runat=server. Then in your page load
use:
If Not IsPostBack so that the controls will only be set up the first time.

Now on postback of the form the controls values won't be overwritten when
you get them via FindControl.

I hope this helps.

(I haven't taken a look at the forum in the past two weeks, I've been
working on a large project, or I would have answered you.)


Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
A

Alvin Bruney

To add a button to your list, add code like this to your itemdatabound
e.item.cells[0].Controls.Add(new radiobuttonlist())

actually you should create your radiobutton outside, give it an ID, set its
value and then add it.
When you want to check the selection in the post, just do a find control on
the id and examine the selection property.

Does that help?

PS. I didn't see this post, i would have replied sooner. It's easier if you
give your questions a good subject so they have a better chance of catching
someone's attention
 
A

ani

Thanks for the reply. I'll try out as said. If I use runat
attribute, the javascript doesn't work. That's the
problem. How do I make both the javascript and
onserverclick event work . The javascript validates the
html controls. By the way, can I have both asp server
controls and html controls, the way that I coded below.
The html controls are returned in the form of the string
from a function. I guess even if I use runat=server on my
controls, it really makes no difference, because the html
control is a text string returned to the page. And , I
cannot have runat=server on the form tag, because my
javascript isn't functioning properly if I use it.
Could you please suggest something else..

Thanks again for the posts.

P.S People are very curious if I say 'IS THERE NO ONE TO
HELP ME' as opposed to the subject being 'cannot use
onserverclick and onclick the same time' :)
 
S

S. Justin Gengo

Ani,

It sounds as if you don't fully understand the differences between classic
asp and .net.

You are correct. If you are simply having a function output raw html to the
page then you can not use the runat=server tag.

The runat=server tag goes inside a control's tags in the .aspx file and
means that the control it is attached to will be evaluated by the server
before it is delivered to the client.

You should take a look at the sample code provided in the tutorials here:

http://samples.gotdotnet.com/quickstart/aspplus/

These tutorials will give you the knowledge you need to understand how .net
works.

Best of luck!

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
A

ani

Now, how do I solve my problem. Should I change my code
now? Can't have have both onserverclick and onclick .I am
a newbie. I'll go thro' the tutorials.But, I need to get
this working soon.
 
R

Randy Rahbar

Why not add validation controls to your project so validation is also done
on the server - instead of using your own validation.
 
S

S. Justin Gengo

Ani,

The way to solve your problem is to learn as quickly as you can how to use
the .Net language correctly. The reason people probably didn't respond to
your posts earlier is because it's easy to tell that you don't understand
how it works yet.

Yes that takes time which we developers are hard pressed to come by. But
trying to code any solution in any language without first learning that
language and learning the intricacies of how it works at the very best gives
you a solution that might work, but not efficiently. The difficulty here is
that your whole approach is questionable.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top