Hello
in my codebehind for a user preference form, i instantiate a new
class, and then call a function in that class. the function calls a
proc which returns a dataset (in this case a single row from the
database with some stored user preferences). this is all done in the
"Not Page.IsPostBack" IF block, so that is only runs the first time a
page is loaded.
what i'm trying to figure out is how to reference individual data
elements from the returned dataset and then pre-populate the form for
the user (meaning they have already stored their choices)
so what i have in codebehind.vb....
Dim myClass As New DBclass
Dim userPrefs As DataSet =
DBclass.GetUserDraftPrefs(Session("groupID"), Session("UserID"))
Dim userPrefCount As Integer = userPrefs.Tables(0).Rows.Count()
If userPrefCount > 0 Then
here is would want to say something like:
ddl1.selectedvalue = "the value pulled from the dataset for saved
dropdownlist1"
and so on for the other form elements
End If
i'm guessing this is pretty straight forward.
don't know the statement/syntax yet though. is it like an array where
each "column" in the dataset would be accessed by an index?
thanks for any insight/code-sample !! 2 1267
simon,
You could process the single row in the table various ways.
One way:
Dim dr As DataRow = myDataset.Tables(0).Rows(0)
Now, assuming you have a column named "ID" and it is the first column in the
row, you could refer to it like this:
dr("ID")
or like this:
dr(0)
Kerry Moorman
"simon" wrote: Hello in my codebehind for a user preference form, i instantiate a new class, and then call a function in that class. the function calls a proc which returns a dataset (in this case a single row from the database with some stored user preferences). this is all done in the "Not Page.IsPostBack" IF block, so that is only runs the first time a page is loaded.
what i'm trying to figure out is how to reference individual data elements from the returned dataset and then pre-populate the form for the user (meaning they have already stored their choices)
so what i have in codebehind.vb....
Dim myClass As New DBclass
Dim userPrefs As DataSet = DBclass.GetUserDraftPrefs(Session("groupID"), Session("UserID"))
Dim userPrefCount As Integer = userPrefs.Tables(0).Rows.Count()
If userPrefCount > 0 Then here is would want to say something like: ddl1.selectedvalue = "the value pulled from the dataset for saved dropdownlist1" and so on for the other form elements End If
i'm guessing this is pretty straight forward. don't know the statement/syntax yet though. is it like an array where each "column" in the dataset would be accessed by an index?
thanks for any insight/code-sample !!
thank you kerry, i believe that is what i'm looking for. going to try
it out tonight!
out of curiousity, what would another way be to do it? learning the
language, so i appreciate any and all tips! take care simon,
You could process the single row in the table various ways.
One way:
Dim dr As DataRow = myDataset.Tables(0).Rows(0)
Now, assuming you have a column named "ID" and it is the first column in the row, you could refer to it like this:
dr("ID")
or like this:
dr(0)
Kerry Moorman
"simon" wrote:
Hello in my codebehind for a user preference form, i instantiate a new class, and then call a function in that class. the function calls a proc which returns a dataset (in this case a single row from the database with some stored user preferences). this is all done in the "Not Page.IsPostBack" IF block, so that is only runs the first time a page is loaded.
what i'm trying to figure out is how to reference individual data elements from the returned dataset and then pre-populate the form for the user (meaning they have already stored their choices)
so what i have in codebehind.vb....
Dim myClass As New DBclass
Dim userPrefs As DataSet = DBclass.GetUserDraftPrefs(Session("groupID"), Session("UserID"))
Dim userPrefCount As Integer = userPrefs.Tables(0).Rows.Count()
If userPrefCount > 0 Then here is would want to say something like: ddl1.selectedvalue = "the value pulled from the dataset for saved dropdownlist1" and so on for the other form elements End If
i'm guessing this is pretty straight forward. don't know the statement/syntax yet though. is it like an array where each "column" in the dataset would be accessed by an index?
thanks for any insight/code-sample !! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ann Morris |
last post by:
INTRODUCTION
One of the most powerful aspects of .NET and Windows Forms is data
binding. Data binding is the process of associating user interface
(UI) elements with a data source to generate a...
|
by: Scott Baird |
last post by:
HELP!!! I've got a DB with two tables (relationships with a
autonumber). The database works just fine, but I've got a report I
simply can't make work.
I've made a query that uses data from...
|
by: Jeremy Dillinger |
last post by:
I have a program setup to pull data from a database. My database table has
things such as (category, Item, price, etc.) In my program I want to have
multiple list boxes that will have a pull down...
|
by: senfo |
last post by:
I've been trying to come up with a way to use the built in ASP.NET
controls to design something that displays the results of a database
query by group like is possible in an Access report to, for...
|
by: mark4asp |
last post by:
I have created two DropDownList controls on my form which I want to
populate with data from an XML file (stored in the xml subdirectory)
Here is the code I use.
It does not work. I shows...
|
by: nmm32 |
last post by:
I have a DataGrid which displays data with the aid of a procedure.
I have tested the procedure inside the database and it is working fine.
I have another procedure which adds another row to the...
|
by: cms3023 |
last post by:
I have a DataGrid which displays data with the aid of a procedure.
I have tested the procedure inside the database and it is working
fine. The table inside the database has data that matches with...
|
by: =?Utf-8?B?TWFyY2Vsbw==?= |
last post by:
Hello,
I am new to pulling data into VB and using DataGridViews..... so this
might be a dumb question but I can not seem to understand how to make this
work.
What I need acomplished:
Exec a...
|
by: giandeo |
last post by:
Hello Experts.
Could you find a solution for this problem please!
I have the following tables in Access Database
Table Name: origin
Fields Names: country, countrycode
Table Name: make...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |