Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 27th, 2005, 06:51 PM
Authorized User
 
Join Date: Jun 2005
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default Wonder if its basic?

I have a set of questions in xml,each of which has different answer types like text,decimal,boolean

I want to display this questions inside a datagrid.
Say a datagrid will have two columns(Question and answer).
But the answer column should contain a text box if answer type is text or decimal,two radio buttons if answer type is boolean,etc.

Seems like I cannot bind a dataset created from xml and have the datagrid display the appropriate answer control for the question,coz if I create a template column for the answer,I could not just place a textbox or radio buttons there for it will depend on the resultsets.

I wonder if I can create a datagrid and add datagrid items programmatically(without binding datagrid to a datasource) and let me decide whether to put a textbox or radio buttons on the second column.
Is this possible or any better approach to this?


Aldwin Enriquez
President,Software Engineer - Narrasoft Philippines Inc.
__________________
\"Dont you ever give up!\"
 
Old June 27th, 2005, 09:24 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Building a dynamic control set has proven to be quite difficult for many people.

One solution I have found when you have a fairly rigid set of controls like in your scenario is to put all the controls in the template that you might need but leave their visible attribute set to false. Then you can turn on the one(s) you want based on the question type. Often this is much easier to manage than trying to get dynamic control addition to work.

-Peter
 
Old July 3rd, 2005, 11:37 PM
Authorized User
 
Join Date: Jun 2005
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default

my problem there is how set the properties of the userControl inside the datagrid with values from the fields in the datasource.

Like I have a BoolFieldControl which contains a RadioButtonList with two items.
I want to put DataSource.Field1 into radiobuttonlist.items[0].Text and the other item with Field2.

I've been playing with OnItemDataBound event but to no avail.

Here's my non-working code inside OnItemDataBound handler:

ucBoolControl boolItem = (ucBoolControl)e.Item.FindControl("UcBoolControl1" );
//boolItem.Option1 = Field1; boolItem is always null though I have rows in the datasource,and how do I get the value of datasource.field1 inside the handler
//boolItem.Option2 = Field2;

Aldwin Enriquez
"Dont you ever give up!"
 
Old July 5th, 2005, 11:01 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You are on the right track. You'll need to figure out why boolItem is coming back null. That seems to be the main issue. Otherwise, that's the right approach.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
visual basic 6.0 flowertear Pro VB 6 3 June 28th, 2013 03:16 PM
Basic Application surendran Java Basics 0 May 24th, 2006 12:20 PM
Basic help questions... mpmahoney Access 2 December 15th, 2004 08:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.