Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is better?
Message
 
 
À
07/04/2008 23:58:49
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Versions des environnements
OS:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01308825
Message ID:
01308986
Vues:
12
>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.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform