Solved

Datagrid + display Row number

Posted on 2004-08-16
5
760 Views
Last Modified: 2011-09-20
i have a datagrid that show standings i want to add a colum that wil display the number of the row ie 1 thru 10, plus also when the use goes to the standings i want their name bold so it stands out, i will get their name form the authentication cookie and it will match the name colum

ie

Position     Name       Pts
1              abcd         10
2              efghk         9
3              keyname    8   <-- currently logged in so this would be highlighted.

Thanks
0
Comment
Question by:dkilby
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 

Author Comment

by:dkilby
ID: 11817620
sorry forgot to add, i am using VB.net
0
 
LVL 21

Accepted Solution

by:
tovvenki earned 250 total points
ID: 11817775
Hi,
for row numbers add a template column as the first column of the grid. As each row is rendered, the code behind the OnItemCreate event will update the text of this column based on the row index from the dataset. Each row of the dataset has an index property that can be used to compute the row number:

Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemCreated
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            e.Item.Cells(0).Text = (e.Item.DataSetIndex + 1).ToString()
        End If

    End Sub

Regards,
venki
0
 

Author Comment

by:dkilby
ID: 11820654
I
0
 
LVL 10

Assisted Solution

by:jnhorst
jnhorst earned 250 total points
ID: 11826182
adding to tovvenki's post:

then check the name against your auth cookie and add <b> & </b> tags to the text of the name cell.  In your sample above, Name is the second column so I will assume the index of the column is 1.

If {authCookie value} = e.Item.Cells(1).Text Then
     e.Item.Cells(1).Text = "<b>" & e.Item.Cells(1).Text & "</b>"
End If

John
0
 
LVL 21

Expert Comment

by:tovvenki
ID: 11827483
Hi,
I am sorry I missed that one. jnhorst is correct add that too.

Regards,
venki
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question