Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Okay, I realize this is a remedial question but I have been looking for an example on how to use a SQL statement (rather than binding a single table) to generate a datagrid and manually assigning coulmns. The closest example I found for some reason loads the datagrid with a "+" only. When you click the "+" it lists the tables. When I click on a table it expands and I see my data. How can I supass these steps? Here's my main goal in case anyone knows of a good example out there:

 

Join 4 tables in a SQL statement

Display roughly 6 columns with my own names (not the field names) and have 1 row display all fields needed (so data from multiple tables)

All but one of the columns are read only text/1 column is a checkbox (when checked that row is deleted)

 

I keep finding examples for ASP.NET and VB6 which uses a "Column" type but cannot find anything in VB.NET to allow me to see the columns when it first loads (rather than the "+") and to add my own columns/column names from multiple tables.

 

Is a datagrid even the best choice for what I want to do? Or would I be better off using a different control? Any advice/links would be appreciated - thanks!

 

Jenn

Posted
Yes, Link to the dataset without specifying any table member. All the tables in the dataset will be accessible.

Auto-suggestion: "I have a life"

Uncontroled thinking: "So what the.."

Posted

PlausiblyDamp - not sure if you quite understood my issue. Say I have three tables:

 

tMainCategories

----------------------

iMainCategoryID

sMainCategoryDesc

 

tSubCategories

--------------------

iSubCategoryID

iMainCategoryID

sMainCategoryDesc

 

tEquipmentItems

----------------------

iEquipmentItemID

iSubCategoryID

sItemDesc

 

Now say in my datagrid I want to display all items along with the main category and sub category it belongs to. In my tEquipmentItems I only have the IDs to those but I want to display the main category description and subcategory description alongside each item. There is not one table in my db that holds all of the information I want to display and therefore I was looking for a way to display a SQL statement rather than a table (so I can join them). I have figured out a way to display a joined SQL statement but cannot figure out how to (a) Name the columns myself (it uses the field name) and (b) Make the columns appear directly on load rather than having to manually click the "+" and then the word "table".

 

Any advice?

Jenn

Posted

YourGatagrid.Expand(-1) opens the +

YourGatagrid.Navigate(0, "Table") to open the table of your choice.

Auto-suggestion: "I have a life"

Uncontroled thinking: "So what the.."

Posted

Have some adapter get the shema automatically for you with

adapter.fill(yourDataset,"Your Table")

Edit the relations, it should have hirarchical records in your datagrid...

Auto-suggestion: "I have a life"

Uncontroled thinking: "So what the.."

Posted

If I understand what you want to do right. Check this link for the solution http://www.codeproject.com/useritems/grid101.asp

I had the same problem with having a join in a datagrid and only wanted to show data without the + for navigation.

 

You will have to create and fill an ArrayList from a DataSet and set the ArrayList as the DataSource for the DataGrid. But check the link it has one example in VB which can save the data as well.

Also you will create columnstyles which must be mapped to a Property which points out the data in the ArrayList.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...