Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically populated GridView

Status
Not open for further replies.

dpdg

Programmer
May 23, 2005
148
US
I have a GridView that I want to use for 2 different stored procedures: one has 6 columns and the other 11. So I want to dynamically populate the grid with the AutoGenerateColumns.

However, I have one column that needs to be formatted to currency in both queries. I can do this with: "CAST(myColumn AS MONEY) AS Amount" and it formats it currency format in the output, but the GridView ignores the formatting. Besides that, I would like to right align the column too.

How do I have my cake and eat it too?
 
See, I want to use the AutoGenerateColumns=True, so therefore I won't be able to use the TemplateField.

I need to be able to format the column dynamically when it's loading since it doesn't exist before.

If that's not possible, then I'll just have to use a separate page for each grid and redirect to the correct page according to the user's choice.
 
I am not following you.. try using the rowdatabound event then to format
 
Now I get it. I can autogenerate the columns and format the rows testing for a certain column name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top