Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra Column In Data Bound DataGridView

Status
Not open for further replies.

gcrane

Programmer
Aug 4, 2014
12
US
In a previous posting (thread) I was creating a small datagridview (dgv) with one column from Active Directory. This time I am trying to use an existing data bound dgv and add a similar column to it. With the code below I am able to add the column, but no data is loaded into it. What am I missing?

Code:
dgvCODView.DataSource = PWordRstTableAdapter.FillBySubmitted(Me.MedSARADataSet.PWordRst)
Dim extraColumn As New DataGridViewColumn
With extraColumn
     .Name = "UserName"
     .HeaderText = "User Name"
     .ReadOnly = True
End With
dgvCODView.Columns.Insert(0, extraColumn)

For Each row As DataGridViewRow In dgvCODView.Rows
     row.Cells("UserName") = GetUserName(domainDN, row.Cells("EmpID"))
Next
 

Is there a reason you want to add the column to the DataGridView instead of the underlying DataTable?

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
No, there is not a known reason for not using the underlying data table (PWordRstTableAdapter). I am new to programming and would like a better understanding about data tables, adapters, etc. This application will be used by several hundred people to submit requests for password resets. With this in mind, I will be creating several DGVs to display various pieces of information. I was hoping to find an efficient way to create views, some from the table, and some with additional columns. Can I add the column to the existing adapter and it won't affect another user looking at the same adapter in a different view?
 

If you add the extra column to the DataTable, it will only be part of that table. If you add a column to the adapter - in the SQL code - the yes, everyone will see that column. That's why I say add the column to the DataTable.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top