Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 6th, 2003, 08:50 AM
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Databidinds question

Hello
I have a form with a datagrid that i bound to a table and
several controls and 1 combobox box. The combox is bound
to a datatable. When i click and a row the grid i want to
read the values and update all the controls of the form
and also the combobox - that has dropdownlist style on.
Here the code :

        Dim dataset3 As New DataSet()
        Dim tabela1 As New DataTable()
        dim cliente as string = 'Delphi'

        SqlDataAdapter2.Fill(dataset3, "clientes")
        tabela1 = dataset3.Tables("clientes")
        dataset3.Tables(0).PrimaryKey() = New DataColumn
() {dataset3.Tables(0).Columns("nome")}

        Dim view As New Data.DataView()
        view.Table = tabela1
        view.RowFilter = "Nome = '" & cliente & "'"

        ComboBox1.DataSource = tabela1
        ComboBox1.DisplayMember = "Nome"

When the form loads it show all clients in combobox1 i i change it to :
        ComboBox1.DataSource = view
        ComboBox1.DisplayMember = "Nome"

It only shows one client. What i want is the combo to contain all clients and to display the searched one.

Any suggestion would be most welcome, thanks.

Kind Regards
Jorge Cavalheiro




Sleep is for the weak.
 
Old June 6th, 2003, 09:50 PM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to bhaving7
Default

As per the qry i undestood was, whn u click on the Grid on Form, the data should be filtered as per the PK value and form controls should have the value of the Gird's Primary Key Value.

As per ur code no need to create a PK in the DataTable, whn u fill the dataset after filling it use the select method of the Dataset and the Pass the Grid's Selected Rows Value in it and Bind to the Controls/Combo u want.


Dim dataset3 As New DataSet()
SqlDataAdapter2.Fill(dataset3, "clientes")

dataset3.Tables("clientes").Select("nome='" & DATAGRID'S SELECTED ROW VALUE & "'")

if isnothing(combobox1.datasource))=FALSE then
     combobox1.datasource=NOTHING
end if


combobox1.datasource=dataset3.Tables("clientes")
combobox1.displaymember="nome"

I Hope this will solve ur problem.
if u any further quieries u can get back to me @






Allways try and U'll Be successful
Bhavin





Similar Threads
Thread Thread Starter Forum Replies Last Post
contains() question... CyanBlue XSLT 3 April 6th, 2006 03:37 AM
c++ question amahja56 C++ Programming 3 February 24th, 2004 02:45 PM
a question gorji C++ Programming 2 August 11th, 2003 07:41 AM
if else question hoonboon69 Javascript 1 August 8th, 2003 07:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.