Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is better?
Message
From
08/04/2008 10:21:59
 
 
To
08/04/2008 09:53:40
General information
Forum:
ASP.NET
Category:
Other
Title:
Environment versions
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01308825
Message ID:
01308998
Views:
13
Hi Naomi,

Sorry if I doubted your understanding, you "get it" ok. Just don't refer to "calling" an event handler next time. <g>

>For me this sounds like we may want to have a GridView class instead of the current implementation.

You should always be working with your own base classes, which are sub-classed from the .NET classes ... just like we did in VFP. <g>

If this functionality is something that you would want in all the grids in your application, then yeah, put it in your MyGridView class. If you only need it for this page and no where else, then you have two choices. Doing it in the event handler like you currently are, or sub-classing your MyGridView class to use here (and put it in your second sub-class).

~~Bonnie




>>Hi Naomi,
>>
>>In one grid I added necessary functionality in RowCreated method. In another grid I just called the same Event Handler grdDeleteUser_RowCreated().
>>
>>Could you post your code? I think we have a terminology issue possibly. As Viv said, you don't *call* Event Handlers, so I can't really be sure if you're understanding this unless I see the code you're trying to use.
>>
>>~~Bonnie
>>
>
>Hi Bonnie,
>
>Here is code in the page ASPX file:
>
>
>
><asp:GridView ID="grdDeleteUsers" runat="server" AutoGenerateColumns="False"
>                                         CellPadding="4"
>                                        DataKeyNames="UserName" AllowSorting="True"
>                                        ForeColor="#333333" GridLines="None" ToolTip="Select user to Delete"
>                                        OnRowDataBound="grdDeleteUsers_RowDataBound"
>                                        Width="379px"
>                                        DataSourceID="odsDeleteGrid" AllowPaging="True" PageSize="5"
>                                        OnRowCreated="grdDeleteUsers_RowCreated">
>                                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
>                                        <EditRowStyle BackColor="#999999" />
>                                        <SelectedRowStyle Backcolor="LightCyan" ForeColor="DarkBlue" Font-Bold="True"/>
>                                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
>                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
>                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
>
>and also for another grid
>
>
><asp:GridView ID="grdvwUsers" runat="server" AutoGenerateColumns="False" CellPadding="4"
>                                        ForeColor="#333333" GridLines="None" AllowPaging="True" PageSize="5"
>                                        OnSelectedIndexChanged="grdvwUsers_SelectedIndexChanged"
>                                        OnRowDataBound="grdvwUsers_RowDataBound" OnPageIndexChanging="grdvwUsers_PageIndexChanging"
>                                        OnRowCreated="grdDeleteUsers_RowCreated"
>
>And this is in the cs file:
>
>protected void grdDeleteUsers_RowCreated(object sender, GridViewRowEventArgs 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;
>            GridView grd = (GridView)sender;
>            if (e.Row.RowType == DataControlRowType.DataRow)
>            {
>
>                if (e.Row.RowState == DataControlRowState.Alternate)
>
>                    rowBackColor = System.Drawing.ColorTranslator.ToHtml(grd.AlternatingRowStyle.BackColor).ToString();
>
>                else rowBackColor = System.Drawing.ColorTranslator.ToHtml(grd.RowStyle.BackColor).ToString();
>
>                e.Row.Attributes.Add("onmouseover", onmouseoverStyle);
>
>                e.Row.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor));
>
>            }
>        }
>
>For me this sounds like we may want to have a GridView class instead of the current implementation.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform