table on a web page which contains info about paint colors. One column
contains the hex value for the color's RGB value. I want to display
info from the table in a grid or table and use the column value from
the RGBHex column to set each row's back ground color. I can just
about do this in my sleep in old style ASP using <%%tags but I would
like to implement it in .NET 2. My website has this implemented in
old ASP here: www.paintmatcher.com/tool/tool.asp Any help is greatly
appreciated.On Mar 17, 1:26 pm, "TF" <TJForw...@.gmail.comwrote:
Quote:
Originally Posted by
the RGBHex column to set each row's back ground color. I can just
about do this in my sleep in old style ASP using <%%tags
it could be the same as in ASP 3:
bgcolor="#<%=hex_value%>"
where "hex_value" is a variable
Here's a snippet of the code created by MS Vis Web Developer 05
Express. The data from the table displays just fine. I want to set
the back color of each row based on the value of the "RGBHex" field.
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="AccessDataSource2"
EmptyDataText="There are no data records to
display.">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Brand" HeaderText="Brand"
SortExpression="Brand" />
<asp:BoundField DataField="Colorname"
HeaderText="Colorname" SortExpression="Colorname" />
<asp:BoundField DataField="RGBValue" HeaderText="RGBValue"
SortExpression="RGBValue" />
<asp:BoundField DataField="RGBHex" HeaderText="RGBHex"
SortExpression="RGBHex" />
</Columns>
</asp:GridView>
Could I use ASP 3 <%%tags inside the BoundField tag? How would I
call the field value using ASP.NET to assign to the variable? Or
maybe there's a better solution than using a GridView. Any other
ideas?
Thanks.
Alexey Smirnov wrote:
Quote:
Originally Posted by
On Mar 17, 1:26 pm, "TF" <TJForw...@.gmail.comwrote:
Quote:
Originally Posted by
the RGBHex column to set each row's back ground color. I can just
about do this in my sleep in old style ASP using <%%tags
>
it could be the same as in ASP 3:
>
bgcolor="#<%=hex_value%>"
>
where "hex_value" is a variable
More see here!
http://www.flash50.com/index.php
On Mar 17, 10:26 pm, "TF" <TJForw...@.gmail.comwrote:
Quote:
Originally Posted by
Here's a snippet of the code created by MS Vis Web Developer 05
Express. The data from the table displays just fine. I want to set
the back color of each row based on the value of the "RGBHex" field.
>
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="AccessDataSource2"
EmptyDataText="There are no data records to
display.">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Brand" HeaderText="Brand"
SortExpression="Brand" />
<asp:BoundField DataField="Colorname"
HeaderText="Colorname" SortExpression="Colorname" />
<asp:BoundField DataField="RGBValue" HeaderText="RGBValue"
SortExpression="RGBValue" />
<asp:BoundField DataField="RGBHex" HeaderText="RGBHex"
SortExpression="RGBHex" />
</Columns>
</asp:GridView>
>
Could I use ASP 3 <%%tags inside the BoundField tag? How would I
call the field value using ASP.NET to assign to the variable? Or
maybe there's a better solution than using a GridView. Any other
ideas?
>
In this case you should rewrite a GridView_RowDataBound event.
Change <asp:GridView ID="GridView1"
OnRowDataBound="GridView1_RowDataBound"...
and add the GridView1_RowDataBound event to your code (code-behind)
C#:
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string c = e.Row.DataItem["RGBHex"]; // e.g. "#000000"
e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml(c);
}
}
I didn't test it but it should work, I think
On Mar 18, 4:20 am, "Alexey Smirnov" <alexey.smir...@.gmail.comwrote:
Quote:
Originally Posted by
On Mar 17, 10:26 pm, "TF" <TJForw...@.gmail.comwrote:
>
>
>
Quote:
Originally Posted by
Here's a snippet of the code created by MS Vis Web Developer 05
Express. The data from the table displays just fine. I want to set
the back color of each row based on the value of the "RGBHex" field.
>
Quote:
Originally Posted by
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="AccessDataSource2"
EmptyDataText="There are no data records to
display.">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Brand" HeaderText="Brand"
SortExpression="Brand" />
<asp:BoundField DataField="Colorname"
HeaderText="Colorname" SortExpression="Colorname" />
<asp:BoundField DataField="RGBValue" HeaderText="RGBValue"
SortExpression="RGBValue" />
<asp:BoundField DataField="RGBHex" HeaderText="RGBHex"
SortExpression="RGBHex" />
</Columns>
</asp:GridView>
>
Quote:
Originally Posted by
Could I use ASP 3 <%%tags inside the BoundField tag? How would I
call the field value using ASP.NET to assign to the variable? Or
maybe there's a better solution than using a GridView. Any other
ideas?
>
In this case you should rewrite a GridView_RowDataBound event.
>
Change <asp:GridView ID="GridView1"
OnRowDataBound="GridView1_RowDataBound"...
>
and add the GridView1_RowDataBound event to your code (code-behind)
>
C#:
>
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
>
if (e.Row.RowType == DataControlRowType.DataRow)
{
string c = e.Row.DataItem["RGBHex"]; // e.g. "#000000"
e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml(c);
>
}
}
>
I didn't test it but it should work, I think
OK. Where do I put that C# code snippet?
On Mar 18, 4:20 am, "Alexey Smirnov" <alexey.smir...@.gmail.comwrote:
Quote:
Originally Posted by
On Mar 17, 10:26 pm, "TF" <TJForw...@.gmail.comwrote:
>
>
>
Quote:
Originally Posted by
Here's a snippet of the code created by MS Vis Web Developer 05
Express. The data from the table displays just fine. I want to set
the back color of each row based on the value of the "RGBHex" field.
>
Quote:
Originally Posted by
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="AccessDataSource2"
EmptyDataText="There are no data records to
display.">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Brand" HeaderText="Brand"
SortExpression="Brand" />
<asp:BoundField DataField="Colorname"
HeaderText="Colorname" SortExpression="Colorname" />
<asp:BoundField DataField="RGBValue" HeaderText="RGBValue"
SortExpression="RGBValue" />
<asp:BoundField DataField="RGBHex" HeaderText="RGBHex"
SortExpression="RGBHex" />
</Columns>
</asp:GridView>
>
Quote:
Originally Posted by
Could I use ASP 3 <%%tags inside the BoundField tag? How would I
call the field value using ASP.NET to assign to the variable? Or
maybe there's a better solution than using a GridView. Any other
ideas?
>
In this case you should rewrite a GridView_RowDataBound event.
>
Change <asp:GridView ID="GridView1"
OnRowDataBound="GridView1_RowDataBound"...
>
and add the GridView1_RowDataBound event to your code (code-behind)
>
C#:
>
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
>
if (e.Row.RowType == DataControlRowType.DataRow)
{
string c = e.Row.DataItem["RGBHex"]; // e.g. "#000000"
e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml(c);
>
}
}
>
I didn't test it but it should work, I think
OK. Where do I put that C# code snippet?
On Mar 18, 4:20 am, "Alexey Smirnov" <alexey.smir...@.gmail.comwrote:
Quote:
Originally Posted by
On Mar 17, 10:26 pm, "TF" <TJForw...@.gmail.comwrote:
>
>
>
Quote:
Originally Posted by
Here's a snippet of the code created by MS Vis Web Developer 05
Express. The data from the table displays just fine. I want to set
the back color of each row based on the value of the "RGBHex" field.
>
Quote:
Originally Posted by
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="AccessDataSource2"
EmptyDataText="There are no data records to
display.">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Brand" HeaderText="Brand"
SortExpression="Brand" />
<asp:BoundField DataField="Colorname"
HeaderText="Colorname" SortExpression="Colorname" />
<asp:BoundField DataField="RGBValue" HeaderText="RGBValue"
SortExpression="RGBValue" />
<asp:BoundField DataField="RGBHex" HeaderText="RGBHex"
SortExpression="RGBHex" />
</Columns>
</asp:GridView>
>
Quote:
Originally Posted by
Could I use ASP 3 <%%tags inside the BoundField tag? How would I
call the field value using ASP.NET to assign to the variable? Or
maybe there's a better solution than using a GridView. Any other
ideas?
>
In this case you should rewrite a GridView_RowDataBound event.
>
Change <asp:GridView ID="GridView1"
OnRowDataBound="GridView1_RowDataBound"...
>
and add the GridView1_RowDataBound event to your code (code-behind)
>
C#:
>
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
>
if (e.Row.RowType == DataControlRowType.DataRow)
{
string c = e.Row.DataItem["RGBHex"]; // e.g. "#000000"
e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml(c);
>
}
}
>
I didn't test it but it should work, I think
OK. Where do I put that C# code snippet?
On Mar 18, 4:20 am, "Alexey Smirnov" <alexey.smir...@.gmail.comwrote:
Quote:
Originally Posted by
On Mar 17, 10:26 pm, "TF" <TJForw...@.gmail.comwrote:
>
>
>
Quote:
Originally Posted by
Here's a snippet of the code created by MS Vis Web Developer 05
Express. The data from the table displays just fine. I want to set
the back color of each row based on the value of the "RGBHex" field.
>
Quote:
Originally Posted by
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="AccessDataSource2"
EmptyDataText="There are no data records to
display.">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Brand" HeaderText="Brand"
SortExpression="Brand" />
<asp:BoundField DataField="Colorname"
HeaderText="Colorname" SortExpression="Colorname" />
<asp:BoundField DataField="RGBValue" HeaderText="RGBValue"
SortExpression="RGBValue" />
<asp:BoundField DataField="RGBHex" HeaderText="RGBHex"
SortExpression="RGBHex" />
</Columns>
</asp:GridView>
>
Quote:
Originally Posted by
Could I use ASP 3 <%%tags inside the BoundField tag? How would I
call the field value using ASP.NET to assign to the variable? Or
maybe there's a better solution than using a GridView. Any other
ideas?
>
In this case you should rewrite a GridView_RowDataBound event.
>
Change <asp:GridView ID="GridView1"
OnRowDataBound="GridView1_RowDataBound"...
>
and add the GridView1_RowDataBound event to your code (code-behind)
>
C#:
>
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
>
if (e.Row.RowType == DataControlRowType.DataRow)
{
string c = e.Row.DataItem["RGBHex"]; // e.g. "#000000"
e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml(c);
>
}
}
>
I didn't test it but it should work, I think
OK. I may be getting this now. I made this the first line of my
default.aspx.
<%@. Page Language="C#" AutoEventWireup="false"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
And this is the contents of the default.aspx.cs file. Renamed my grid
GridView2 by the way.
protected void GridView2_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string c = e.Row.DataItem["RGBHex"];
e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml(c);
}
}
Getting these compilation errors.
c:\...Default.aspx.cs(1,11): error CS1518: Expected class, delegate,
enum, interface, or struct
c:\...Default.aspx.cs(6,27): error CS1001: Identifier expected
c:\...Default.aspx.cs(9,1): error CS1022: Type or namespace
definition, or end-of-file expected
I feel like I'm getting close but I just can't get it. Thank you for
your help.
TF
On Mar 18, 9:24 pm, "TF" <TJForw...@.gmail.comwrote:
Quote:
Originally Posted by
On Mar 18, 4:20 am, "Alexey Smirnov" <alexey.smir...@.gmail.comwrote:
>
>
>
>
>
Quote:
Originally Posted by
On Mar 17, 10:26 pm, "TF" <TJForw...@.gmail.comwrote:
>
Quote:
Originally Posted by
Quote:
Originally Posted by
Here's a snippet of the code created by MS Vis Web Developer 05
Express. The data from the table displays just fine. I want to set
the back color of each row based on the value of the "RGBHex" field.
>
Quote:
Originally Posted by
Quote:
Originally Posted by
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="AccessDataSource2"
EmptyDataText="There are no data records to
display.">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Brand" HeaderText="Brand"
SortExpression="Brand" />
<asp:BoundField DataField="Colorname"
HeaderText="Colorname" SortExpression="Colorname" />
<asp:BoundField DataField="RGBValue" HeaderText="RGBValue"
SortExpression="RGBValue" />
<asp:BoundField DataField="RGBHex" HeaderText="RGBHex"
SortExpression="RGBHex" />
</Columns>
</asp:GridView>
>
Quote:
Originally Posted by
Quote:
Originally Posted by
Could I use ASP 3 <%%tags inside the BoundField tag? How would I
call the field value using ASP.NET to assign to the variable? Or
maybe there's a better solution than using a GridView. Any other
ideas?
>
Quote:
Originally Posted by
In this case you should rewrite a GridView_RowDataBound event.
>
Quote:
Originally Posted by
Change <asp:GridView ID="GridView1"
OnRowDataBound="GridView1_RowDataBound"...
>
Quote:
Originally Posted by
and add the GridView1_RowDataBound event to your code (code-behind)
>
Quote:
Originally Posted by
C#:
>
Quote:
Originally Posted by
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
>
Quote:
Originally Posted by
if (e.Row.RowType == DataControlRowType.DataRow)
{
string c = e.Row.DataItem["RGBHex"]; // e.g. "#000000"
e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml(c);
>
Quote:
Originally Posted by
}
}
>
Quote:
Originally Posted by
I didn't test it but it should work, I think
>
OK. I may be getting this now. I made this the first line of my
default.aspx.
>
<%@. Page Language="C#" AutoEventWireup="false"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
>
And this is the contents of the default.aspx.cs file. Renamed my grid
GridView2 by the way.
>
protected void GridView2_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string c = e.Row.DataItem["RGBHex"];
e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml(c);
>
}
}
>
Getting these compilation errors.
>
c:\...Default.aspx.cs(1,11): error CS1518: Expected class, delegate,
enum, interface, or struct
c:\...Default.aspx.cs(6,27): error CS1001: Identifier expected
c:\...Default.aspx.cs(9,1): error CS1022: Type or namespace
definition, or end-of-file expected
>
I feel like I'm getting close but I just can't get it. Thank you for
your help.
>
TF- Hide quoted text -
>
- Show quoted text -
Mate, you have to start from the basic.
It told you that you miss a class, that is you have to define the
_Default
Remember, you said <%@. Page ... Inherits="_Default"
<!----- This is the name of your class
So, the code-behind should be like this:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
...............code here...............
}
On Mar 17, 7:26 am, "TF" <TJForw...@.gmail.comwrote:
Quote:
Originally Posted by
Very newbie question and I hope this is the right group. I have a
table on a web page which contains info about paint colors. One column
contains the hex value for the color's RGB value. I want to display
info from the table in a grid or table and use the column value from
the RGBHex column to set each row's back ground color. I can just
about do this in my sleep in old style ASP using <%%tags but I would
like to implement it in .NET 2. My website has this implemented in
old ASP here: www.paintmatcher.com/tool/tool.asp Any help is greatly
appreciated.
Got it to work now. Thank you all very much!
0 comments:
Post a Comment