| View previous topic :: View next topic |
| Author |
Message |
oasisok Newbie
Joined: 15 Sep 2004 Posts: 7 Location: Oklahoma
|
Posted: Sep 17th, 2004 10:51 AM Post subject: [RESOLVED] - merging two columns together in a DataTable... |
|
|
I am pretty weak on using databases (obviously). I have a DataSet that has two tables in it. I need to get columns from another table and combine them into one of the tables in the dataset. What is the easiest way to do this?
James
Last edited by oasisok on Sep 29th, 2004 01:48 PM; edited 2 times in total |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Sep 18th, 2004 01:34 AM Post subject: |
|
|
Hi oasisok,
I believe what you need is the ItemDataBound I use it to display content
from multiple tables.
Here is an example
[vb:1:4390356074]Private Sub displaymembers_ItemDataBound(ByVal sender As
System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
_
Handles displaymembers.ItemDataBound
If Not CType(e.Item.FindControl("accessRole"),
System.Web.UI.WebControls.Label) Is Nothing Then
Dim _AccessRole As Label = CType(e.Item.FindControl
("accessRole"), System.Web.UI.WebControls.Label)
' Lookup the role (You could also move this find code into
the manager class for reuse)
Dim _Role As Roles
For Each _Role In _Roles
If _Role.role_id = _AccessRole.Text Then
' Replace with the roles name
_AccessRole.Text = _Role.role_name
Exit For
End If
Next
End If
Dim _Name As String = CType(DataBinder.Eval
(e.Item.DataItem, "FirstName"), String) & " " & CType(DataBinder.Eval
(e.Item.DataItem, "LastName"), String)
CType(e.Item.FindControl("Name"), Label).Text = _Name
End If
End Sub[/vb:1:4390356074] I am not exactly sure how it all works but feel free to write back to me if you require further help.
I hope this helps you out.
Thanks! _________________ Code Snippets, Tutorials, Utilities, Controls
Low cost Web Hosting
Hosting starts at as low as $4 per year!
Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags! |
|
| Back to top |
|
oasisok Newbie
Joined: 15 Sep 2004 Posts: 7 Location: Oklahoma
|
Posted: Sep 22nd, 2004 09:40 AM Post subject: |
|
|
I checked the code and I really don't understand it at all. I figured out how to add a column to a table by using the DataColumnCollection.add. I still can't figure out how to take the data from one column and add it to a new column in a different table.
I don't want to add the value through the DataGrid (as shown in the sample code), I want this done before the DataSet is set up on the DataGrid. |
|
| Back to top |
|
oasisok Newbie
Joined: 15 Sep 2004 Posts: 7 Location: Oklahoma
|
Posted: Sep 29th, 2004 01:44 PM Post subject: [Resolved] merging two columns together in a DataTable... |
|
|
Just FYI, I was able to figure it out. Instead of trying to add columns to a table that was already created, I found out I had to create a new dataset and datatable. then take the data from the tables I already have and add them to the new table. It takes a lot of code, but that's the best way to do it.
Just thought I'd let y'all know.
James |
|
| Back to top |
|
|