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

Conditionning columns

5 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Myriam
Top achievements
Rank 1
Myriam asked on 23 Sep 2008, 01:22 PM
Hello
I would like to have conditionning columns
Here is how I would like to have

For now I have 2 columns in my grid (I have more than that but this is actually what I need for that problem)
This grid in link to a sqldatasouce.
I have a field in that sqldatasource that called 'Confirm'
when 'Confirm' contain the text 'OK' I would like to display 1 column :

<

telerik:GridTemplateColumn HeaderText="">

<ItemTemplate>

<asp:Label ID="LbConfirme" Text='<% # ConfirmeImage(Container) %>' runat="server"></asp:Label>

</ItemTemplate>

</telerik:GridTemplateColumn>

When 'Confirm' contain nothing or "" I woule like to display the other column:

<

telerik:GridButtonColumn ButtonType=LinkButton UniqueName="LkConfirmer" CommandName="ConfirmerUnItem" Text="Confirmer">

</telerik:GridButtonColumn>
Which allow me to confirm the item

On each row I have to look if  the 'Confirm' field is 'Ok' or nothing and then show the right column
Does it have a way to do that?
Thanks in advance

5 Answers, 1 is accepted

Sort by
0
Myriam
Top achievements
Rank 1
answered on 23 Sep 2008, 08:12 PM
Hello There
I found how to do what I wanted, but it goes in the ItemDatabound 6 times, when I have only 5 rows.

on each row I have a NO_PANIER which is unique.
If I look in the webform I have my No_Panier like this:
18528
18529
18527
18521
18531

In the ItemDataBound Sub I put a breakpoint on that line
NoPan = CStr(item("NO_PANIER").Text)
each time that it stop on it I take the NoPan value
it gives me this:
18528
18527
18531
18528
18527
18531
Seems like it does it only once on twice
(by the way, on these 3 No_Panier my ItemDataBound is working fine, for the 2 others, it shows me both colums(LkConfirmer and ConfirmeImage))

Here is the code

Public Sub RadGrid1_ItemDataBound1(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound

Dim item As GridDataItem

Dim conf As String

Dim NoPan As String

If e.Item.OwnerTableView.Name = "Detail" Then

If e.Item.ItemType = GridItemType.Item Then

item =

CType(e.Item, GridDataItem)

conf =

CStr(item("CONFIRM").Text)

NoPan =

CStr(item("NO_PANIER").Text)

If conf = "OK" Then

item(

"LkConfirmer").Visible = False

Else

item(

"ConfirmeImage").Visible = False

End If

End If

End If

End Sub

0
Accepted
Vlad
Telerik team
answered on 24 Sep 2008, 07:01 AM
Hi Myriam,

Here is an example how to check only GridDataItems:

If TypeOf e.Item Is GridDataItem Then
'Your code goes here
End If

Greetings,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Myriam
Top achievements
Rank 1
answered on 24 Sep 2008, 12:59 PM
Thanks Vlad
This is working!!!!
0
Myriam
Top achievements
Rank 1
answered on 24 Sep 2008, 01:31 PM
I still get a little problem
It shows the header of both column.
I don't mind if I can only see the header of the same column but I should be able to hide always the header of one column only.
does it have a way to do this?
Thanks in advance
0
Myriam
Top achievements
Rank 1
answered on 30 Sep 2008, 01:16 PM
Any Idea?
Tags
Grid
Asked by
Myriam
Top achievements
Rank 1
Answers by
Myriam
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or