I have a gridview with AutoGenerateCol umns=true that is presenting a challenge to me.
Challenge #1
The data structure from the database server follows:
Product |Qty |Jan-09|Qty|Feb-09|Qty|Mar-09 etc
-----------------------------------------------------------------
CD|1.00 |$100.00|5.00|$ 500.00|7.00|$70 0.00 etc
DVD|2.00 |$400.00|7.00|$ 700.00|8.00|$80 0.00 etc
****** But the gridview control renders the Qty columns differently, I am getting the following columns from my gridview control.
Product |Qty |Jan-09|Qty1|Feb-09|Qty2|Mar-09 etc
-----------------------------------------------------------------
CD|1.00 |$100.00|5.00|$ 500.00|7.00|$70 0.00 etc
DVD|2.00 |$400.00|7.00|$ 700.00|8.00|$80 0.00 etc
I will like to have the column names "Qty" remain as "Qty" as generated by SQL
Challenge #2
How can I ensure that the Qty column is not rendered as type money in my RowDataBound event which I am using to calculate the totals?
It is important that I keep AutoGenerateCol umns=true so the gridview control can change dynamically based on the different SQL queries generated by a stored procedure.
Qty is a derived column
SUM(case when order_month = 2 Then Qty ELSE 0.00 END) AS Qty,
SUM(case when order_month = 2 Then total_price ELSE 0.00 END) AS [Feb-09],
SUM(case when order_month = 3 Then Qty ELSE 0.00 END) AS Qty,
SUM(case when order_month = 3 Then total_price ELSE 0.00 END) AS [Mar-09],
etc
Challenge #1
The data structure from the database server follows:
Product |Qty |Jan-09|Qty|Feb-09|Qty|Mar-09 etc
-----------------------------------------------------------------
CD|1.00 |$100.00|5.00|$ 500.00|7.00|$70 0.00 etc
DVD|2.00 |$400.00|7.00|$ 700.00|8.00|$80 0.00 etc
****** But the gridview control renders the Qty columns differently, I am getting the following columns from my gridview control.
Product |Qty |Jan-09|Qty1|Feb-09|Qty2|Mar-09 etc
-----------------------------------------------------------------
CD|1.00 |$100.00|5.00|$ 500.00|7.00|$70 0.00 etc
DVD|2.00 |$400.00|7.00|$ 700.00|8.00|$80 0.00 etc
I will like to have the column names "Qty" remain as "Qty" as generated by SQL
Challenge #2
How can I ensure that the Qty column is not rendered as type money in my RowDataBound event which I am using to calculate the totals?
It is important that I keep AutoGenerateCol umns=true so the gridview control can change dynamically based on the different SQL queries generated by a stored procedure.
Qty is a derived column
SUM(case when order_month = 2 Then Qty ELSE 0.00 END) AS Qty,
SUM(case when order_month = 2 Then total_price ELSE 0.00 END) AS [Feb-09],
SUM(case when order_month = 3 Then Qty ELSE 0.00 END) AS Qty,
SUM(case when order_month = 3 Then total_price ELSE 0.00 END) AS [Mar-09],
etc
Comment