fill two droplist

F

Frank Dulk

As I do to fill out two droplist of different tables in the event open of
the webforms.

I get to fill out one, but when I try two says that cannot open another
connection.
 
F

Frank Dulk

That is the code that I am sweating for filling out the dropdownlist1 with
the records of the table1.
How do I do to fill out other dropdownlist2 with the records of another
table2?

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

If Not IsPostBack Then

Dim strSql As String

Dim conexao As OleDbConnection

Dim dscmd As OleDbDataAdapter

Dim ds As DataSet

conexao = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data
source=C:\Inetpub\wwwroot\Database_acesso1\talao.mdb;")

conexao_Open()

Try

strSql = "select distinct tplt_desc from TblTipoLente order by tplt_desc"

dscmd = New OleDbDataAdapter(strSql, conexao)

ds = New DataSet

dscmd.Fill(ds, "TblTipoLente")

Me.DropCategorias.DataTextField = "tplt_desc"

Me.DropCategorias.DataValueField = "tplt_desc"

Me.DropCategorias.DataSource = ds.Tables("TblTipoLente").DefaultView

Me.DropCategorias.DataBind()

Me.DropCategorias.Items.Insert(0, New ListItem("Selecione seu tipo de
lente...", ""))

Finally

conexao.Close()

End Try

End If

End Sub

End Class
 
J

jmbledsoe

I've been using a tool called the DataSet Toolkit to handle Fills and
Updates of multiple DataTables like you're doing. It will manage your
connection for you so you don't need to worry about creating a new one,
and it will even write the SQL to fill your table at runtime, so you
won't need to do that either. You can find it here:

http://www.hydrussoftware.com

John B.
http://johnsbraindump.blogspot.com
 
F

Frank Dulk

ok Gaurav Vaish, will test in your way.
Thank you very much John B. will also see that program.

Does he/she/you have how in the dropdownlist to show the name and does keep
the id in the table, as if it was two columns?
 
F

Frank Dulk

Exactly that.
Thank you very much.

would have as in a text box to type +1 or -1 or +74 or...
but would have to impose a limit up to +170 or -170

But has to have that mask.+ or -
 
F

Frank Dulk

Everything well, I am going trying to seek something that helps me.

I am in I await .
Thank you.
 
F

Frank Dulk

Does excuse, but where do I glue that code?
My knowledge is very limited.


Gaurav Vaish (www.EduJini.IN) said:
Frank,

Here's what you can start with...

<input id='box1' type='text' onchange='validateValue(this)'
onkeypress='return checkKey(this, event)' ... />

JavaScript initialization of the text box (for last validated value):
var box1 = getElementById('box1');
box1.validValue = -1; //Initial value

Javascript functions:

function checkKey(sender, e)
{
// Use this if you want to validate each key-press
// Return true if you accept the character typed, false if you
don't want to be accepted
return true;
}

function validateValue(tb)
{
var value = tb.value;
var setVal = tb.validValue; // The last stored valid value
try
{
var intval = int.Parse(value);
if(intval >= -170 && intval <= 170)
{
setVal = intval;
}
} catch { }
tb.validValue = setVal; // This is for internal use
tb.value = setVal; // This is what keeps changing as
user types
}

For exact and advanved javascript, you may like to go to flashy places
like www.dynamicdrive.com etc.
 
F

Frank Dulk

I tried to copy and to glue in the it paginates for testing and gave
mistake.
Excuse, but I didn't get.
 
F

Frank Dulk

I am going of the a glance yes. I really need.

But if wants me it orders a small page example I am thanked.
 
F

Frank Dulk

I don't have idea of how to work with scripts. A small sample page in vb.net
would be an initial point.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top