Thursday, November 8, 2012

Color issues

I thought my code for alternate row colors was faulty - or a cascading issue.
In reality - my screen doesn't show the color

e.g. #f6f6f6 

IE9

tools-> compatibility view settings ->intranet by default is on

regardless of setting you can set the web page with the following meta

<meta http-equiv="X-UA-Compatible" content="IE=8" />

Monday, November 5, 2012

Basic linq syntax group by on datatable



            DataTable dt = new DataTable();
            dt.Columns.Add("a", typeof(string));
            dt.Columns.Add("b", typeof(string));
            dt.Columns.Add("c", typeof(string));
            DataRow dr =  dt.NewRow();
            dr[0] = "a - row1";
            dr[1] = DBNull.Value;
            dr[2] = "c -row1";
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "a -row2";
            dr[1] = "b -row2";
            dr[2] = "c -row2";

            dt.Rows.Add(dr);

            var subjects = dt.AsEnumerable().GroupBy(row => new { a = row.Field<string>("a"),c=  row.Field<string>("c")}).Select(i => new { Subject = i.Key, Count = i.Count()}) ;
            foreach (var subject in subjects)
            {
                Response.Write(subject.Subject);
            }


results

{ a = a - row1, c = c -row1 }{ a = a -row2, c = c -row2 }
{ a = a - row1, b = , c = c -row1 }{ a = a -row2, b = b -row2, c = c -row2 }

Basic date Regular Expressions



  1. "dd/mm/yyyy","(3[01]|[12][0-9]|0[1-9])/(0[1-9]|1[012])/[1-2][0-9][0-9][0-9]"
  2. "dd-mmm-yy","(3[01]|[12][0-9]|0[1-9])[-/][a-zA-Z][a-zA-Z][a-zA-Z][-/][1-2][0-9][0-9][0-9]"
  3. "MM/dd/yyyy","(0[1-9]|1[012])/(3[01]|[12][0-9]|0[1-9])/[1-2][0-9][0-9][0-9]"
  4. "yyyy-mm-dd","[1-2][0-9][0-9][0-9][-/](0[1-9]|1[012])[-/](3[01]|[12][0-9]|0[1-9])"  
  5. "yyyy/mm/dd","[1-2][0-9][0-9][0-9]/(0[1-9]|1[012])/(3[01]|[12][0-9]|0[1-9])" 
I cheated on MMM , I know
 

Anomolies of Spreadsheetgear with dates

1)Spreadsheetgear converts "-" into "/"
                so if you have a spreadsheet with a date thus


2011-01-03


                  Spreadsheetgear will convert it to
                                 
                                      2011/01/03

2) Spreadsheetgear describes DD/MM/YYYY,MM/DD/YYYY and YYYY/MM/DD with "\/", but not
YYYY-MM-DD

therefore

 
excel format:DD/MM/YYYY sh/g format:dd\/mm\/yyyy - 01/01/2011
excel format:MM/DD/YYYY sh/g format:mm\/dd\/yyyy - 02/01/2011
excel format:YYYY-MM-DD sh/g format:yyyy/mm/dd - 2011/01/03
excel format:DD-MMM-YYYY sh/g format:dd/mmm/yyyy - 04/Jan/2011
excel format:YYYY/MM/DD sh/g format:yyyy\/mm\/dd - 2011/01/05

3) a date coming from a CSV with a value of 04-Jan-2011 will be converted to d-mmm-yy, 4-Jan-11

4) an excel file that has dates formatted as "Date" will be read by excel with the default culture. Therefore, if you open the file with your own custom culture - this will be the format of the "Date" cells.




Looping through controls with Jquery

I had a situation where components were being created by a custom control inheriting a repeater - the repeater had a dropdown and was being propogated multiple times but always ended with "blah" in the name - the issue was setting all the dropdowns under certain conditions. this is how I did it:


 onClick ='$("[id$=blah]").each( function() { if (this.options[1].value== "whatever"  && this.selectedIndex ==0 ){ this.options[1].selected = true }   ;}      );'