Solved

Customize a Role Grid View, bound to Roles.GetAllRoles

Posted on 2009-07-13
2
486 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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 …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

18 Experts available now in Live!

Get 1:1 Help Now