programmatic access to sqldatasource dataset (culture change problem) RRS feed

  • Question

  • DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

    Ok. Working perfectly. It's copying all the data to dv - great!
    But after all, i've just changed culture="es-ES" in page declaration and dv is always null and rowcount=0?

    Of course when i move declaration working one more time correct.
    Help appreciated
    Monday, September 3, 2007 2:58 PM


  • Ok. I'm replaying on my own question...
    Of course in this case dv was null cause datasource was also empty.

    Problem was following:
     I had a query to database:
    SqlDataSource1.SelectCommand = "select * from action where date>'" + start + "' and date<'" + end + "'";
    string start = Calendar1.TodaysDate.AddDays(-30).ToString();
                string end = Calendar1.TodaysDate.AddDays(30).ToString();

    After changing culture settings calendar's date was formated differently and was not fitting to database query.
    I just reformat the dates that where going to the query:
    string start = String.Format("{0:yyyy-MM-dd}", Calendar1.TodaysDate.AddDays(-30));
    string end = String.Format("{0:yyyy-MM-dd}", Calendar1.TodaysDate.AddDays(30));

    Hope one day it's gonna be helpfull.

    Monday, September 3, 2007 9:02 PM