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

Dynamic ASP page on the fly using C#

Hi All,

Is it possible at all, and if yes, then how? Or it's very/extremely hard to
do that? Maybe somebody knows...)

I'm writing a Web App using VS2003/C#/MSSQL.

I'm currently having about 100 different questions, some questions are
having relations to another questions and should be published only if the
parent has an answer, the most part of the questions should have answers,
some don't. The type of the questions can be very different - Simple Text,
RadioButton Lists, CheckBox Lists, CheckBox MultiSelection Lists, DropDown
Lists, and few more. The questions can be changed any time and we can not
write a hardcoded asp web page with all these questions and answers. So I
need some approach that can help me to create an ASP page on the fly using
the question list, the answer list, the questions type, etc. The ideal way -
if we can edit these answers. And all questions and answers should be shown
on one, maybe long web page.

Any standard grid that I know doesn't work, because I need to show all these
question types friendly to the client and regarding to the database
information.

What can I do? Use a Tree View to show all questions or what? I'm not
absolutely sure that it will work. It's not a Windows Application, it's a
Web Application with its own restrictions of the interface.

Any ideas or suggestions? Maybe somebody has already done a project like
this? Can I do something without grid? And what approach can be used to show
all this information dynamically?

Thanks,
Dmitri
Nov 15 '05 #1
1 1675
Jax
I recently made a page that needed to create items from the results of a database. I didn't opt for a datagird or list because I wanted more functionality and things like drop down lists and buttons
I used a data repeater
What this does is write out a certain html item template per item in the collection or data object you bind it to
For example I had an object called Garment, this had an image, a selection of sizes, selection of colours, price and of course name
I created a template with labels, images, dropdownlists and a button to select the item
You can store the questions in a database and modify the DB to update the site

Getting a handle on the items after they've been made is a little more tricky. I found it useful to add made up tags to the controls that would tell me which item they pertained to
e.g (psuedocode
<asp:Repeater id = repeater1 runat = server><ItemTemplate><table style = "Z-Index = 105 Left =<%# GetLeft() %> Top = <%# GetTop() %>"><tr><td
// The databinder.Eval returns the name property, field or column depending on what you are binding it to
<asp:Label id = label runat = server value = <%# DataBinder.Eval(Container.DataItem, "Name") %> madeUpTag = <%# GetNumber()%>></td></tr></table></ItemTemplate></asp:Repeater

In the .cs behin

protected System.Web.UI.WebControls.Repeater repeater1
int left
int top
int number
protected string GetLeft(

return left.ToString()

protected string GetTop(

top+=20
return top.ToString()

protected string GetNumber(

number++
return number.ToString()

protected Page_Load(

if(IsPostBack!=true

ArrayList al = FunctionToGetStuffFromDB()
repeater1.DataSource = al
repeater1.DataBind()

If you want to use drop down lists I found the only way to populate them is by cycling through all of the controls in repeater1 then all the controls in the template
If you've used your made up attributes you can find out which item it is and databind the dropdown accordingly
One word of warning, when you databind the drop down list you lose any made up tags, so it's best to

string myMadeUpAttribute = ddl.Attributes["myMadeUpAttribute"]
ddl.DataSource = someArrayList
ddl.DataBind()
ddl.Attributes["myMadeUpAttribute"] = myMadeUpAttribute

do that

I hope that helps, and if anyone knows a better way I'd like to know about it

jax
Nov 15 '05 #2

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

Similar topics

4
by: Daniel Keller | last post by:
Hello! I'm trying to set up a page system using "dynamic" SSI. That means that I normally use the following on my website: <!--#include virtual="file.inc" --> Now I want to make this...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
7
by: Abraham Luna | last post by:
how do i stop the dynamic validators from breaking explorer if i use a dynamic validator and move to a different control it breaks explorer and i can type in the page when i'm not supposed to....
8
by: Sandy Pittendrigh | last post by:
I have a how-to-do-it manual like site, related to fishing. I want to add a new interactive question/comment feature to each instructional page on the site. I want (registered) users to be able...
6
by: Tom | last post by:
I am developing my pages on my development machine and then copying to the production server. I am not pre-compiling, I am using the 'dynamic compile' feature. This is working fine except that...
10
by: jflash | last post by:
Hello all, I feel dumb having to ask this question in the first place, but I just can not figure it out. I am wanting to set my site up using dynamic urls (I'm assuming that's what they're...
5
by: pittendrigh | last post by:
There must be millions of dynamically generated html pages out there now, built by on-the-fly php code (and jsp, perl cgi, asp, etc). Programatic page generation is transparently useful. But...
3
by: brian.turner | last post by:
This is sort of a design/javascript question. It involves CSS rendering in dynamic areas of a page using IE. E 6 & 7 HI There, We've created some example static html pages (using CSS) that...
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.