By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,592 Members | 1,958 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,592 IT Pros & Developers. It's quick & easy.

Class 'System.Data.SqlClient.SqlDataAdapter' cannot be indexed because it has no default property.

P: n/a
Hi,
I'm trying to something quite straightforward, populate a datagrid
with certain fields after selecting from a dropdownlist. The books I
have don't seem to give an example of how to do this ( particularly
from within VStudio 2003 ) and it's driving me to distraction.

daNumber1 selects the au_id and au_lname
SqlDataAdapter1 is attempting to take the parameter @au_id to populate
the datagrid1, but the SqlDataAdapter1 is giving the error "Class
'System.Data.SqlClient.SqlDataAdapter' cannot be indexed because it
has no default property." I don't understand what the default ought to
be...

As I say, I have no book examples to work from, so I'm just cobbling
together other bits in an attempt to understand/get it to work -
apologies if my poor code offends thee!

Thanks,
bob

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlConnection1.Open()
daNumber1.Fill(dsNumber1)
If Not Page.IsPostBack Then
lstCategory.DataSource = dsNumber1()
lstCategory.DataValueField = "au_id"
lstCategory.DataTextField = "au_lname"
lstCategory.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
DataGrid1.DataSource =
SqlDataAdapter1(lstCategory.SelectedValue)
DataGrid1.DataBind()
End Sub
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In your button click perhaps try this:

DataGrid1.DataSource = dsNumber1.Tables[0].Select( "au_id = " +
lstCategory.SelectedValue );
DataGrid1.DataBind();

Now this is dependent on the dsNumber1 being defined globally to the page.
Also, I am assuming dsNumber1 is a DataSet with the first table (zero based
indexes or indii ) having the DataGrid information.

bill
"Bob of the West" <bo*************@yahoo.com> wrote in message
news:3a**************************@posting.google.c om...
Hi,
I'm trying to something quite straightforward, populate a datagrid
with certain fields after selecting from a dropdownlist. The books I
have don't seem to give an example of how to do this ( particularly
from within VStudio 2003 ) and it's driving me to distraction.

daNumber1 selects the au_id and au_lname
SqlDataAdapter1 is attempting to take the parameter @au_id to populate
the datagrid1, but the SqlDataAdapter1 is giving the error "Class
'System.Data.SqlClient.SqlDataAdapter' cannot be indexed because it
has no default property." I don't understand what the default ought to
be...

As I say, I have no book examples to work from, so I'm just cobbling
together other bits in an attempt to understand/get it to work -
apologies if my poor code offends thee!

Thanks,
bob

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
SqlConnection1.Open()
daNumber1.Fill(dsNumber1)
If Not Page.IsPostBack Then
lstCategory.DataSource = dsNumber1()
lstCategory.DataValueField = "au_id"
lstCategory.DataTextField = "au_lname"
lstCategory.DataBind()
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
DataGrid1.DataSource =
SqlDataAdapter1(lstCategory.SelectedValue)
DataGrid1.DataBind()
End Sub

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.