Adding rows to gridview

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working on a questionaire, and I'd like to add the questions to a
gridview, so that each row (of two "columns" each) has the question in one
field, and the editable section (where the user will enter the answer) in the
next field. The questions are not stored in a table, and I'm thinking of
saving the answers manually (i.e. no datasource). Is this possible?
This is a web app using asp.net 2.0.

THanks.
 
If you're using ASP.NET 2.0, you might be able to use the built-in Profiles
database to store the questions and answers. Depending on the number of
respondents, you *might* get away with using the .Net 2.0 Updatable Xml
DataSource Control

http://www.chaliy.com/Sources/Default.aspx

Ken
Microsoft MVP [ASP.NET]
 
if you use a DataSource you have to be bound to that DataSource, for example
a XML file,
the other way arround is to build a DataTable and Bound the GridView to the
the DataTable

adding rows to the DataTAble is as easy as

Dim dataRowObject as DataRow
dataRowObject("column1") = "value 1"
dataRowObject("column2") = "value 2"

DataTableObject.Rows.Add( dataRowObject )

and then you can end up with

GridView.DataSource = DataTableObject
GridView.Bind()


the DataTable is very powerfull and you should read more about it, there's a
lot of examples over the web
you can also, remove, sort, perform operations and a lot of other nice
things to the DataTable object.
 
I am not sure Profile would be the best answer, unless this is a one time
quiz per user. If you ever wanted to add additional tests or additional
questions, you would end up with inconsistent profiles, or worse.
Interesting solution, however*. :-)

* I love outside of the box thinking
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think Outside the Box!
*************************************************
Ken Cox said:
If you're using ASP.NET 2.0, you might be able to use the built-in
Profiles database to store the questions and answers. Depending on the
number of respondents, you *might* get away with using the .Net 2.0
Updatable Xml DataSource Control

http://www.chaliy.com/Sources/Default.aspx

Ken
Microsoft MVP [ASP.NET]


VMI said:
I'm working on a questionaire, and I'd like to add the questions to a
gridview, so that each row (of two "columns" each) has the question in
one
field, and the editable section (where the user will enter the answer) in
the
next field. The questions are not stored in a table, and I'm thinking of
saving the answers manually (i.e. no datasource). Is this possible?
This is a web app using asp.net 2.0.

THanks.
 
Anything is possible. You can save the answer off a variety of ways. One is
to use ADO.NET DataTables (as Bruno has suggested). You can then save using
ADO.NET (as a csv file, for example) or just save the XML as XML. It really
depends on how you are later going to consume the data. As XML, you simply
suck the XML back into a DataTable and start rolling. In fact, you can use
multiple tables and save what, in essence, becomes a mini file based
database. If you store a file per user, you would be best served to either
consistently name (which can be tricky if you end up with two people with
similar names, for example) or have another file saved that tells which file
matches which user.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think Outside the Box!
*************************************************
 
Back
Top