Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Class or User Control or what?
Message
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01316015
Message ID:
01316411
Views:
23
Very nice!

I added one more method to the class I downloaded
protected override void OnRowCreated (GridViewRowEventArgs e)
        {
            base.OnRowCreated(e); 
            //Colors charts - see http://www.1netcentral.com/color-chart.html
            string onmouseoverStyle = "this.style.backgroundColor='#0bf'"; // Deepskyblue

            string onmouseoutStyle = "this.style.backgroundColor='@BackColor'";

            string rowBackColor = String.Empty;
           
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

                if (e.Row.RowState == DataControlRowState.Alternate)

                    rowBackColor = System.Drawing.ColorTranslator.ToHtml(this.AlternatingRowStyle.BackColor).ToString();

                else rowBackColor = System.Drawing.ColorTranslator.ToHtml(this.RowStyle.BackColor).ToString();

                e.Row.Attributes.Add("onmouseover", onmouseoverStyle);

                e.Row.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor));

            }
        }
>Bonnie,
>
>Hi again. I decied to create a custom class. Since I still haven't done it myself before, I decided to first search the Web and found this great article
>http://aspnet.4guysfromrolla.com/articles/020608-1.aspx#postadlink
>
>So, I'm going to take this class, add my own minor enhancement and use it instead of the regular GridView control. I hope I can understand the implementation details and would be more confident creating and using custom classes after this experience.
>
>>Naomi,
>>
>>I come from the WinForms world rather than web forms, but I doubt if the class and sub-class concept is any different between the two ... although the mechanics of how to do it might be different between the two, so don't ask me *how* to it with web stuff. <g>
>>
>>Yes, you should have a base class for your grid ... that's where that RowCreated method should go. And yes, for your two different pages, I'd have one page that's sub-classed from the other. Maybe you only need a method or a property on the parent page for setting the datasource of the grid.
>>
>>~~Bonnie
>>
>>
>>
>>
>>>Hi everybody,
>>>
>>>I'm wondering how we should approach this problem in .NET.
>>>
>>>I have two very similar WEB pages (in fact, I created the second Page by just copying the first and then making the changes).
>>>
>>>These two pages have the GridView which is the same in appearance (HTML) and Events except for the DataSource.
>>>
>>>In VFP I would simply save this grid as a class and figure out a way to use different Data Source.
>>>
>>>What are my options in .NET and how can I convert this GridView into the common control?
>>>
>>>Also I added some code in RowCreated method that highlights the GridView record on mouseover. I'd like to somehow carry this functionality to all Grids used in the application (the pages are already designed).
>>>
>>>How should I approach this problem?
>>>
>>>Thanks a lot in advance for the ideas and some guidance.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform