Solved

change GridView buttonfield styles

Posted on 2006-03-27
3
739 Views
Last Modified: 2008-01-09
Hello-
I have a ASP 2.0 gridview that can have either a template button or a regular select button to make a selection.  The problem that I have is my entire site is set under a particular style and I've changed all the other default asp buttons to match.  It is annoying to me to see the default windows buttons when the rest of the site has a nice sleek look.  Using an image button is not an option.  If there are any ideas out there I would greatly appreciate it.

Thanks-
LT
0
Comment
Question by:lyntron4545
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
srivatsavaye earned 500 total points
ID: 16305562
You could try this


    Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PreRender
        Dim i As Integer
        For i = 0 To GridView1.Rows.Count - 1
            gridview1.Rows(i).Cells(0).CssClass=your cssfile
        Next
    End Sub

if your select button is in the first column
0
 

Author Comment

by:lyntron4545
ID: 16305670
srivatsavaye-

Thanks for the quick response.  If I wanted to add the following to my code where would I do that at?

btnPrice.style="filter:progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#D0D0D0,endColorStr=#ffffff)
          progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')"/>
btnPrice.Attributes.Add("OnMouseOver", "this.style.cursor='hand';this.style.border='Inset';style.borderWidth='2'")
btnPrice.Attributes.Add("OnMouseOut", "this.style.cursor='default';this.style.border='Solid'; style.borderWidth='1'")

Thanks again-
LT
0
 

Author Comment

by:lyntron4545
ID: 16305846
srivatsavaye-

I've tried the code you gave me and I've inserted the code that I had a question on.  The only problem that I have is the page still renders with the default button but once I roll over them they change to the corrrect style.  What is happening????

Here is my code.
Protected Sub dgvPartPrice_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvPartPrice.PreRender
            Dim i As Integer
            For i = 0 To dgvPartPrice.Rows.Count - 1
                Dim btnPrice As Button = CType(dgvPartPrice.Rows(i).Cells(1).Controls.Item(0), Button)

                '- Gradient background on the button -'
                btnPrice.Style.Add("filter:", "progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#D0D0D0,endColorStr=#ffffff) progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')")

                '- Rollover affects -'
                btnPrice.Attributes.Add("OnMouseOver", "this.style.cursor='hand';this.style.border='Inset';style.borderWidth='2'")
                btnPrice.Attributes.Add("OnMouseOut", "this.style.cursor='default';this.style.border='Solid'; style.borderWidth='1'")
            Next
End Sub
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

Title # Comments Views Activity
ASP.NET e-commerce website 4 59
error on the asp.net page 1 33
Word Directory is not in the drop down list 4 26
Reset asp.net login password 4 34
AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

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

20 Experts available now in Live!

Get 1:1 Help Now