This is a migrated thread and some comments may be shown as answers.

Change data in MasterTableView

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ronnie
Top achievements
Rank 1
Ronnie asked on 09 Sep 2008, 05:12 PM
I have a datagrid that is pulling a simple query "SELECT * FROM PROJECT" and in the project table, I have multiple fileds that have an ID to another table within the database.  One of the ID's is to a representative and could be in the PROJECT table multiple times so I can't really link it to the table in my original select statement. 

How can I change the column text from the ID to the name of that representative when the datatable is being populated.  I assume that it will have to be in the ItemDataBound routien.  I have written a function that will return the name of the representative by passing it the ID so I can use something like this to populate the name.

Functions.GetRepNameByID(e.Item.DataItem(

"PROJECT_ASSIGN_ID"))

Right now the column displays the ID "2" instead of the name "Joe Bob".  I would like to display the name instead of the ID.

I tried doing something like this, but it won't let me change the DataItem since it was originally an integer:

If
(TypeOf e.Item Is GridDataItem) Then
    e.Item.DataItem("PROJECT_ASSIGN_ID") = Functions.GetRepNameByID(e.Item.DataItem("PROJECT_ASSIGN_ID"))
End If

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 10 Sep 2008, 08:32 AM
Hi Ronnie,

You need to change the cell text. Here is an example:

If
(TypeOf e.Item Is GridDataItem) Then
    CType(e.Item, GridDataItem)("YourColumnUniqueName").Text = "YourText"
End If


Sincerely yours,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Ronnie
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or