Solved

Customize a Role Grid View, bound to Roles.GetAllRoles

Posted on 2009-07-13
2
484 Views
Last Modified: 2012-08-14
Hello,
I have set up membership in an ASP.NET application.

I need to show all the Roles of the application in a GridView GV1.

so wrote in some event :
GV1.DataSource = Roles.GetAllRoles()
GV1.DataBind()

It worked fine, and the Roles are displayed in one column in GV1, having a header of ITEM.
I need to change the header Text to Role for Instance,
How can i do this?
thanks
I am using VB
0
Comment
Question by:Nyana22
  • 2
2 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 24845024
This is one way...there might be some more simple way which I might not be aware of:
Use GridView RowDataBound Event like below:

Protected Sub GV1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    If e.Row.RowType = DataControlRowType.Header Then
        For Each cell As TableCell In e.Row.Cells
            cell.Text = "Role"
        Next
    End If
End Sub

Ref:
http://www.rosshawkins.net/archive/2007/04/15/adding-tooltips-to-gridview-headers.html.aspx
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 24845047
My bad...you don't need a For Each loop just set like below:
Assuming it as first column....i.e. index=0...

 If e.Row.RowType = DataControlRowType.Header Then
        e.Row.Cells(0).Text = "Role"
    End If
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now