Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net how to put conditions on gridview
    primarykey
    data
    text
    <p>So I have connected a grid to a database where my database contains values of only 1, 2, and 3. I want to have it so that every box that has a 1 is green, 2 is yellow, and 3 is red.</p> <p>My questions is where should i put the conditioning code and what language should i do it in? </p> <p>The following information is just my gridview and the data i am linking it to.</p> <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" &gt; &lt;Columns&gt; &lt;asp:BoundField DataField="Line" HeaderText="Line" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" ItemStyle-BackColor="#FF6699" /&gt; &lt;asp:BoundField DataField="Jan" HeaderText="Jan" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="Feb" HeaderText="Feb" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="Mar" HeaderText="Mar" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="Apr" HeaderText="Apr" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="May" HeaderText="May" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="Jun" HeaderText="Jun" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="Jul" HeaderText="Jul" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="Aug" HeaderText="Aug" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="Sep" HeaderText="Sep" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="Oct" HeaderText="Oct" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="Nov" HeaderText="Nov" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;asp:BoundField DataField="Dec" HeaderText="Dec" ItemStyle-Width="75" ItemStyle-HorizontalAlign="Right" /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:dashboardConnectionString %&gt;" SelectCommand="SELECT line AS Line, [2012-01-31] AS 'Jan', [2012-02-29] AS 'Feb', [2012-03-31] AS 'Mar', [2012-04-30] AS 'Apr', [2012-05-31] AS 'May', [2012-06-30] AS 'Jun', [2012-07-31] AS 'Jul', [2012-08-31] AS 'Aug', [2012-09-30] AS 'Sep', [2012-10-31] AS 'Oct', [2012-11-30] AS 'Nov', [2012-12-31] AS 'Dec' FROM (Select line, report_month, state FROM [Monthly_State]) AS sourcetable PIVOT ( MAX(state) FOR report_month IN ([2012-01-31], [2012-02-29], [2012-03-31], [2012-04-30], [2012-05-31], [2012-06-30], [2012-07-31], [2012-08-31], [2012-09-30], [2012-10-31], [2012-11-30], [2012-12-31]) ) as pivottable; "&gt; &lt;/asp:SqlDataSource&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload