Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Pre-Populating checkboxes and textboxes from db


Message #1 by "Tim Farrell" <timothy.farrell@c...> on Tue, 3 Dec 2002 16:24:23
Say I have a form that I am using to populate a database and that form 
contains textboxes, checkboxes and radio buttons.

Say that I want to also use this form to edit any existing records already 
in my db.  In this manner I would get dual use out of one form.

Question:

How do I get each of these types of controls to per-populate based upon 
data in the db?  So the name fields would already have text in them, any 
checkboxes that were previously check would be checked, and the same for 
any radio buttons.

Thanks for your help.

Sincerely,

Tim
Message #2 by "Carole D Sullivan" <carolesullivan@e...> on Thu, 5 Dec 2002 17:10:38
I don't know of any 'automatic' way to do this.  I have a list of all 
available checkboxes from the database, then the checked values are 
retrieved from another database record.  Loop thru the databound list of 
checkboxes and 'select' the ones that should be checked:

'check appropriate boxes, depending on what screens the operator has 
'for this function
        For Each row In DsOperScreens1.Tables(0).Rows
            For item = 0 To cblstScreens.Items.Count - 1
                scrnNumber = System.Int32.Parse(row("Screen_Number"))
                If cblstScreens.Items.Item(item).Value = scrnNumber Then
                    cblstScreens.Items.Item(item).Selected() = True
                End If
            Next
        Next


Same logic applies to radio buttons.

Carole
> Say I have a form that I am using to populate a database and that form 
c> ontains textboxes, checkboxes and radio buttons.

> Say that I want to also use this form to edit any existing records 
already 
i> n my db.  In this manner I would get dual use out of one form.

> Question:

> How do I get each of these types of controls to per-populate based upon 
d> ata in the db?  So the name fields would already have text in them, 
any 
c> heckboxes that were previously check would be checked, and the same 
for 
a> ny radio buttons.

> Thanks for your help.

> Sincerely,

> Tim
Message #3 by "Farrell, Timothy" <Timothy.Farrell@C...> on Thu, 5 Dec 2002 12:25:38 -0500
Carole,

Thanks for taking the time to reply (I think you were the first).  I guess
what I was driving at was something like:
<INPUT TYPE="radio" NAME="" <% If rs("databaseBoolean") = True then
response.write ("checked") %> >.

I just wasn't sure if the use of "rs" is still the way to go in .net.

As mentioned, my goal was to be able to use the original form for edit
purposes as well but I would like to be able to display what checkboxes or
radio buttons were selected as well.

Thanks much!

Cheers,

Tim

-----Original Message-----
From: Carole D Sullivan [mailto:carolesullivan@e...]
Sent: Thursday, December 05, 2002 12:11 PM
To: aspx_beginners
Subject: [aspx_beginners] Re: Pre-Populating checkboxes and textboxes
from db


I don't know of any 'automatic' way to do this.  I have a list of all 
available checkboxes from the database, then the checked values are 
retrieved from another database record.  Loop thru the databound list of 
checkboxes and 'select' the ones that should be checked:

'check appropriate boxes, depending on what screens the operator has 
'for this function
        For Each row In DsOperScreens1.Tables(0).Rows
            For item = 0 To cblstScreens.Items.Count - 1
                scrnNumber = System.Int32.Parse(row("Screen_Number"))
                If cblstScreens.Items.Item(item).Value = scrnNumber Then
                    cblstScreens.Items.Item(item).Selected() = True
                End If
            Next
        Next


Same logic applies to radio buttons.

Carole
> Say I have a form that I am using to populate a database and that form 
c> ontains textboxes, checkboxes and radio buttons.

> Say that I want to also use this form to edit any existing records 
already 
i> n my db.  In this manner I would get dual use out of one form.

> Question:

> How do I get each of these types of controls to per-populate based upon 
d> ata in the db?  So the name fields would already have text in them, 
any 
c> heckboxes that were previously check would be checked, and the same 
for 
a> ny radio buttons.

> Thanks for your help.

> Sincerely,

> Tim



The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 

Message #4 by "Carole D Sullivan" <carolesullivan@e...> on Thu, 5 Dec 2002 18:46:08
Tim, I see what you mean.  It is my understanding that recordsets are not 
used in .net, you have data adapters (which are often used with 
datagrids) for sets of data returned from a query and the data reader 
which works well for single row result sets.

I am coding with Visual Studio .net and use the 'code-behind' pages 
whenever possible for my VB code, it just seems cleaner.  I don't miss 
having VBScript and HTML all on the same page.

Happy coding, C

> Carole,

Thanks for taking the time to reply (I think you were the first).  I guess
what I was driving at was something like:
<INPUT TYPE="radio" NAME="" <% If rs("databaseBoolean") = True then
response.write ("checked") %> >.

I just wasn't sure if the use of "rs" is still the way to go in .net.

As mentioned, my goal was to be able to use the original form for edit
purposes as well but I would like to be able to display what checkboxes or
radio buttons were selected as well.

Thanks much!

Cheers,

Tim

-----Original Message-----
From: Carole D Sullivan [mailto:carolesullivan@e...]
Sent: Thursday, December 05, 2002 12:11 PM
To: aspx_beginners
Subject: [aspx_beginners] Re: Pre-Populating checkboxes and textboxes
from db


I don't know of any 'automatic' way to do this.  I have a list of all 
available checkboxes from the database, then the checked values are 
retrieved from another database record.  Loop thru the databound list of 
checkboxes and 'select' the ones that should be checked:

'check appropriate boxes, depending on what screens the operator has 
'for this function
        For Each row In DsOperScreens1.Tables(0).Rows
            For item = 0 To cblstScreens.Items.Count - 1
                scrnNumber = System.Int32.Parse(row("Screen_Number"))
                If cblstScreens.Items.Item(item).Value = scrnNumber Then
                    cblstScreens.Items.Item(item).Selected() = True
                End If
            Next
        Next


Same logic applies to radio buttons.

Carole
> Say I have a form that I am using to populate a database and that form 
c> ontains textboxes, checkboxes and radio buttons.

> Say that I want to also use this form to edit any existing records 
already 
i> n my db.  In this manner I would get dual use out of one form.

> Question:

> How do I get each of these types of controls to per-populate based upon 
d> ata in the db?  So the name fields would already have text in them, 
any 
c> heckboxes that were previously check would be checked, and the same 
for 
a> ny radio buttons.

> Thanks for your help.

> Sincerely,

> Tim



The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or 
disclose
it to anyone else. If you received it in error please notify us 
immediately
and then destroy it. 

Message #5 by "Farrell, Timothy" <Timothy.Farrell@C...> on Thu, 5 Dec 2002 14:04:52 -0500
Carole,

I am working with VS.Net as well.  Have you ever used this scenario before
using DataAdapters?  I have to figure that I am not the only person out
there in .net land has a form that I need to checkoff check boxes based on
data from the database.

Thanks again for your help!

Tim

-----Original Message-----
From: Carole D Sullivan [mailto:carolesullivan@e...]
Sent: Thursday, December 05, 2002 1:46 PM
To: aspx_beginners
Subject: [aspx_beginners] Re: Pre-Populating checkboxes and textboxes
from db


Tim, I see what you mean.  It is my understanding that recordsets are not 
used in .net, you have data adapters (which are often used with 
datagrids) for sets of data returned from a query and the data reader 
which works well for single row result sets.

I am coding with Visual Studio .net and use the 'code-behind' pages 
whenever possible for my VB code, it just seems cleaner.  I don't miss 
having VBScript and HTML all on the same page.

Happy coding, C

> Carole,

Thanks for taking the time to reply (I think you were the first).  I guess
what I was driving at was something like:
<INPUT TYPE="radio" NAME="" <% If rs("databaseBoolean") = True then
response.write ("checked") %> >.

I just wasn't sure if the use of "rs" is still the way to go in .net.

As mentioned, my goal was to be able to use the original form for edit
purposes as well but I would like to be able to display what checkboxes or
radio buttons were selected as well.

Thanks much!

Cheers,

Tim

-----Original Message-----
From: Carole D Sullivan [mailto:carolesullivan@e...]
Sent: Thursday, December 05, 2002 12:11 PM
To: aspx_beginners
Subject: [aspx_beginners] Re: Pre-Populating checkboxes and textboxes
from db


I don't know of any 'automatic' way to do this.  I have a list of all 
available checkboxes from the database, then the checked values are 
retrieved from another database record.  Loop thru the databound list of 
checkboxes and 'select' the ones that should be checked:

'check appropriate boxes, depending on what screens the operator has 
'for this function
        For Each row In DsOperScreens1.Tables(0).Rows
            For item = 0 To cblstScreens.Items.Count - 1
                scrnNumber = System.Int32.Parse(row("Screen_Number"))
                If cblstScreens.Items.Item(item).Value = scrnNumber Then
                    cblstScreens.Items.Item(item).Selected() = True
                End If
            Next
        Next


Same logic applies to radio buttons.

Carole
> Say I have a form that I am using to populate a database and that form 
c> ontains textboxes, checkboxes and radio buttons.

> Say that I want to also use this form to edit any existing records 
already 
i> n my db.  In this manner I would get dual use out of one form.

> Question:

> How do I get each of these types of controls to per-populate based upon 
d> ata in the db?  So the name fields would already have text in them, 
any 
c> heckboxes that were previously check would be checked, and the same 
for 
a> ny radio buttons.

> Thanks for your help.

> Sincerely,

> Tim



The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or 
disclose
it to anyone else. If you received it in error please notify us 
immediately
and then destroy it. 




The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 

Message #6 by "Carole D Sullivan" <carolesullivan@e...> on Fri, 6 Dec 2002 17:12:10
Tim, the example I used earlier uses a data adapter to populate the 
dataset, which is the datasource for the checkboxlist control.  
For each dataset row, I loop thru the checkboxes, when I get a match, I 
check the box.  I should actually exit when I find a match as well.

C

> Carole,

I am working with VS.Net as well.  Have you ever used this scenario before
using DataAdapters?  I have to figure that I am not the only person out
there in .net land has a form that I need to checkoff check boxes based on
data from the database.

Thanks again for your help!

Tim

-----Original Message-----
From: Carole D Sullivan [mailto:carolesullivan@e...]
Sent: Thursday, December 05, 2002 1:46 PM
To: aspx_beginners
Subject: [aspx_beginners] Re: Pre-Populating checkboxes and textboxes
from db


Tim, I see what you mean.  It is my understanding that recordsets are not 
used in .net, you have data adapters (which are often used with 
datagrids) for sets of data returned from a query and the data reader 
which works well for single row result sets.

I am coding with Visual Studio .net and use the 'code-behind' pages 
whenever possible for my VB code, it just seems cleaner.  I don't miss 
having VBScript and HTML all on the same page.

Happy coding, C

> Carole,

Thanks for taking the time to reply (I think you were the first).  I guess
what I was driving at was something like:
<INPUT TYPE="radio" NAME="" <% If rs("databaseBoolean") = True then
response.write ("checked") %> >.

I just wasn't sure if the use of "rs" is still the way to go in .net.

As mentioned, my goal was to be able to use the original form for edit
purposes as well but I would like to be able to display what checkboxes or
radio buttons were selected as well.

Thanks much!

Cheers,

Tim

-----Original Message-----
From: Carole D Sullivan [mailto:carolesullivan@e...]
Sent: Thursday, December 05, 2002 12:11 PM
To: aspx_beginners
Subject: [aspx_beginners] Re: Pre-Populating checkboxes and textboxes
from db


I don't know of any 'automatic' way to do this.  I have a list of all 
available checkboxes from the database, then the checked values are 
retrieved from another database record.  Loop thru the databound list of 
checkboxes and 'select' the ones that should be checked:

'check appropriate boxes, depending on what screens the operator has 
'for this function
        For Each row In DsOperScreens1.Tables(0).Rows
            For item = 0 To cblstScreens.Items.Count - 1
                scrnNumber = System.Int32.Parse(row("Screen_Number"))
                If cblstScreens.Items.Item(item).Value = scrnNumber Then
                    cblstScreens.Items.Item(item).Selected() = True
                End If
            Next
        Next


Same logic applies to radio buttons.

Carole
> Say I have a form that I am using to populate a database and that form 
c> ontains textboxes, checkboxes and radio buttons.

> Say that I want to also use this form to edit any existing records 
already 
i> n my db.  In this manner I would get dual use out of one form.

> Question:

> How do I get each of these types of controls to per-populate based upon 
d> ata in the db?  So the name fields would already have text in them, 
any 
c> heckboxes that were previously check would be checked, and the same 
for 
a> ny radio buttons.

> Thanks for your help.

> Sincerely,

> Tim



The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or 
disclose
it to anyone else. If you received it in error please notify us 
immediately
and then destroy it. 




The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or 
disclose
it to anyone else. If you received it in error please notify us 
immediately
and then destroy it. 


  Return to Index