473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Very Basic DataGrid Help Needed

jm
I manually put a datagrid in on a form. I then added this code to an
event to populate it:

OdbcConnection conn = new OdbcConnection("DSN=CardBase");
sqlCardHolders = "SELECT * FROM tblcardholders " +
"WHERE last_name LIKE '%" + txtLastName.Text + "%'";
DataSet rs = new DataSet();
conn.Open();
OdbcDataAdapter myOdbcAdapter = new
OdbcDataAdapter(sqlCardHolders, conn);
myOdbcAdapter.Fill(rs);
dgridSearchResults.DataSource = rs;
dgridSearchResults.SetDataBinding(rs,"CardHolders" );

I do not see anything in the datagrid except a little box with a plus
and I can eventually expand it to show the row and it lets me edit it,
etc.

If I turn off Row Headers Visible, I don't even see the little plus.

I just want to query the database and have the rows show up. I don't
want to edit them or anything. I just can't find anything that shows
me some basic tutorial on this. Thank you for any help.
Nov 16 '05 #1
1 1255
jm,

The DataGrid is doing that because you are assigning it a DataSet as a
DataSource. A DataSet contains a collection of Tables and possibly
Relationships between those tables. If you want to only represent the
DataTable in the collection represented by your single query, you'll need to
specify the DataSource as being the DefaultView of the table you want to
show.

For example:
dgridSearchResults.DataSource = rs.Tables[0].DefaultView;

Hope that helps,

Patrick Altman

"jm" <jo*************@yahoo.com> wrote in message
news:c6**************************@posting.google.c om...
I manually put a datagrid in on a form. I then added this code to an
event to populate it:

OdbcConnection conn = new OdbcConnection("DSN=CardBase");
sqlCardHolders = "SELECT * FROM tblcardholders " +
"WHERE last_name LIKE '%" + txtLastName.Text + "%'";
DataSet rs = new DataSet();
conn.Open();
OdbcDataAdapter myOdbcAdapter = new
OdbcDataAdapter(sqlCardHolders, conn);
myOdbcAdapter.Fill(rs);
dgridSearchResults.DataSource = rs;
dgridSearchResults.SetDataBinding(rs,"CardHolders" );

I do not see anything in the datagrid except a little box with a plus
and I can eventually expand it to show the row and it lets me edit it,
etc.

If I turn off Row Headers Visible, I don't even see the little plus.

I just want to query the database and have the rows show up. I don't
want to edit them or anything. I just can't find anything that shows
me some basic tutorial on this. Thank you for any help.

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chankama | last post by:
Hi. I am attempting to display the contents of a database table on a CE device. I was using a DataTable object, as the datasource of the DataGrid, to accomplish this task. The problem with this...
5
by: BethInAK | last post by:
Thank you in advance for any possible help you have to offer, before I pull my hair out! I am incredibly frustrated attempting to learn asp.net. Its really pissing me off. Please help. ...
1
by: thegame | last post by:
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls Hello, I have an interesting dilemma. I have an ASPX page with two user controls (two ASCXs). ...
2
by: Fay Yocum | last post by:
BEWARE beginner questions!! I have some experience in Access but never as much as I want or need. I have decided to get in on VB.Net. I would only rate myself in Access as a...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
10
by: Aaron Smith | last post by:
If I have a datagrid and the bound data file only have 4 rows in it, the grid will show the 4 rows. However, there is blank space below that until it reaches the bottom of the grid. Is there a way...
10
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
5
hussaini
by: hussaini | last post by:
please tell me any 1 printing code in datagrid in visual basic 6 in detail ----- Hello seniors members hope u will tell me ..... i have created a form in visual basic 6 so in the form there is a...
1
nateraaaa
by: nateraaaa | last post by:
While working on a recent project I discovered how useful the CommandArgument property can be. I needed to determine the record_id of a row displayed in my datagrid. When the user clicked the Edit...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.