Ken Robertson's Blog

Ramblings of a .NET developer

DataGrid Help: Dynamically columned DataGrid and WebControls?

Hopefully someone can offer some insight into this... I've been starting to pull my hair out, and I am too young to go bald.

On this one page, I dynamically generate a couple of datagrids all though code (nothing in the webpage itself).  It is for a survey, and depending on how many question types are in the system, it has to generate a datagrid for each, and then it needs columns for each of the responses (Yes/No,  Excellent/Very Good/Good/Poor/Horrible).  So I can't use a static datagrid, since I don't know how many grids I need, and the number of columns will vary, so no way to use a <asp:RadioButton> for the responses.

I've got the tables to all show up.  I create the datagrid, create a datatable and add all of the columns and then the rows.  If I put the plain HTML for the radio button into the table, the radio shows up, but I cannot get its values when I submit it.  Not even though Request[”question1”].  If I create a RadioButton object and set the column to it, nothing shows up.  The column just disappears.  I've tried declaring an array of RadioButtons within the scope of the whole page, and still doesn't work.

Anyone have any ideas?  Some better way I could do it?  If I declare the DataGrid within the scope of the whole class will it work?  If it helps, you can check out my code.  Please!  Before I go bald!

Posted: Feb 28 2004, 08:55 AM by qgyen | with 8 comment(s)
Filed under: ,

Comments

John Mason said:

Ken, had the same problem and it can be done...as soon as I get back to my development server I'll post the code. What I would tell you though is that the standard datagrid is a pain in the ...
We have used a number of super grids that work with less code, are supported with examples...saves the hair. You probably know but you can find a number of grids on http://www.asp.net

For the time saved, the cost for most of these is reasonable.

John
# February 28, 2004 12:42 PM

Ramon Smits said:

Seems to me you are building your dynamic grid at the wrong time. Your grid has to be build up before ASP.NET will check your page for changes. Build the grid in the OnInit method and try to read the values in your OnLoad and everything will be fine. You will have to do this *every* time the page or control is loaded.

One thing that is quite difficult to maintain is the state of your page. You will have to know the state to build the correct grid. You could use query parameters or the viewstate to do this.

You don't supply any code and nowhere you mention where you are building your datagrid. Please supply more info if I did not understand your problem 100%.
# February 28, 2004 4:53 PM

Sumeet said:

I have a very similar problem in an interactive questionniare using datagrids generated at page load time depending upon the number of questions and answers. Still haven't worked out how to preserve the state of the check boxes in one of the grids columns which contain the user's response to the questions.
After sleeping on the problem for several weeks - I have decided to try and use XML either cached/written do disk to save the data from the check box column for each user session. During the ItemDataBound event of the datagrid check to whether a recent XML exists for that particular session & set of questions and rebuild the state of the checkbox column from this.
An overkill perhaps, but I am too fed up to come up with any solution.
# February 28, 2004 7:53 PM

TrackBack said:

# February 28, 2004 11:07 PM

icons downloads said:

<a href="finance.blog.techweb.com.cn/.../2592.html"> Do not take to heart!</a>

# October 7, 2012 3:56 PM

icon package said:

<a href="fr.downloadstock.biz/.../The-Best-Metro-Icon-Creator.html"> In my opinion, it is an interesting question, I will take part in discussion. Together we can come to a right answer. I am assured.</a>

# October 9, 2012 12:19 AM

icons package said:

 I do not see your logic

wiki.blogorganization.com/index.php

BestPictDesign

# December 3, 2012 12:38 PM

windows icons said:

P.S. Please review our <a href="http://find.wp8design.com">design portfolio</a> for Doors2012.

Website Branding Through Graphic Design

A great web design is not just about using attractive colours and putting together the navigation menus. Rather, it is about branding the website in a way that it attracts the targeted audience. While graphic design is all about visual appeal, it should also put across a message to the vsiitors. By incorporating the principles of graphic design in your web design, you have to form a unique identity that your visitors and customers can relate to and recognise easily.Many web designers often make the mistake of overusing or misusing graphic images on the website. Too much of graphic design makes the website look cluttered and too little or dull graphic images can make the site look bland. The trick is to use graphic design throughout the website in measured proportions. Some of the areas where graphic images and design can be used on a website include corporate logos, navigation buttons, mastheads and footers, image maps, bullet points, background images, photos and image maps. All these areas on the website have to be dedsigned in a way that it leaves a lasting impression on the minds of thevisitors.Some of the graphic design elements that must be added to a web ddesign are discussed below:Website colours: The purpose of investing in graphic design services while building a website is to gain a competitive edge and attract more visitors. Colours play a huge role in catching the attention, and during web design, it should be given high priority. The graphic designer should choose colours that complement the industry that you are targeting. For example, if your website is about women's apparel, the colours should be selected from the palettes of pinks, reds and purples that appeal to the female sensibility. Thus, it is important to choose right colours and blend them with the theme of the website.Typography: The fonts used throughout the web design have to be addressed by a graphic designer. The different fonts used in the website should not only complement each other but also the content on each of the web pages. The typography has to make the content appealing and readable. It is advisable that you choose familiar fonts that add a unifying element to the web design.Social media integration: One needs to blend the links to the social media profiles of a company with its website. Just by placing social media icons on your website does not bring effective results. To give your site a distinct edge, you can blend the social media icons with the colours and theme of the website by customising them.When you incorporate these elements of graphic design to your web design, the site is sure to rise above the rest and get a distinctive identity on the Internet. Through website branding, you stand a chance of getting higher visitors, enhancing the conversion rate, leads, sales and revenue. In Sydney, you can find several web designers and graphic designers who have an expertise in both the domains and can help in building a website that is not only visually appealing but also enhances the user experience.

# December 13, 2012 3:20 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)