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

Reading a valuemeber from cell...

2 Answers 28 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Krzysztof
Top achievements
Rank 1
Krzysztof asked on 20 Aug 2009, 01:02 PM
Hello Experts. Here's what I try to do. I have a column in which the user can select some text to which is assigned a value.:

 


Dim
ds_typ_czujnika As New DataTable

 

ds_typ_czujnika.Columns.Add(

"id")

 

ds_typ_czujnika.Columns.Add(

"naz")

 

Dim myCommand As SqlCommand

 

 

Dim dr As SqlDataReader

 

conn_dodatkowe.Open()

myCommand =

New SqlCommand("select id_typ as id, nazwa as naz from tab_urzadzenia_typy where akt = 'True' order by nazwa", conn_dodatkowe)

 

myCommand.CommandType = CommandType.Text

dr = myCommand.ExecuteReader()

 

While dr.Read()

 

ds_typ_czujnika.Rows.Add(dr(0), dr(1))

 

End While

 

dr.Close()

conn_dodatkowe.Close()

 


Dim
k0 As New
GridViewLookUpColumn()

 

k0.FieldName =

"typ_czujnika"

 

k0.FieldAlias =

"typ_czujnika"

 

k0.UniqueName =

"typ_czujnika"

 

k0.HeaderText = lng.zwroc_napis_z_nazwy_elementu(

"typ_czujnika")

 

k0.DataSource = ds_typ_czujnika

k0.DisplayMember =

"naz"

 

k0.ValueMember =

"id"

 

 

Me.gv_ustawienia.Columns.Add(k0)

Now, I have  drag&drop event and I can read the values of columns, including a pre-selected text from k0. Is there any way to read the value id (k0.value member) assigned to that text directly from this row ? 

Thank's a lot for help.

 

Dim

 

p As System.Drawing.Point = gv_ustawienia.PointToClient(New System.Drawing.Point(e.X, e.Y))

 

 

Dim element As RadElement = gv_ustawienia.ElementTree.GetElementAtPoint(p)

 

 

Dim cell As GridCellElement = TryCast(element, GridCellElement)

 

 

Dim row As GridRowElement = Nothing

 

 

 

 

If cell IsNot Nothing And Not (TypeOf (element) Is GridHeaderCellElement) Then

 

 

 

row = cell.RowElement
....

2 Answers, 1 is accepted

Sort by
0
Accepted
Nick
Telerik team
answered on 21 Aug 2009, 10:51 AM
Hi Krzysztof,

Thank you for contacting us. I think that you need the following code snippet:

YourCellElement.RowInfo.Cells[YourCellElement.ColumnIndex].Value 

and in VB.NET:

YourCellElement.RowInfo.Cells(YourCellElement.ColumnIndex).Value  

I hope that helps. Do not hesitate to write me back if you have further questions.

Greetings,
Nick
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Krzysztof
Top achievements
Rank 1
answered on 21 Aug 2009, 11:05 AM
Thank you for your reply. Telerik controls are great and once again exceded my expectations.
Tags
GridView
Asked by
Krzysztof
Top achievements
Rank 1
Answers by
Nick
Telerik team
Krzysztof
Top achievements
Rank 1
Share this question
or