I have an Ultrawebgrid that is loaded dynamically once when the page first loads, via sql dataset from a MSSQL2005 database. I am using the NET3.5, 10.3.20103.2134 version of the control(please do not suggest upgrade, as this is not an option). I have set the formatting in the InitializeLayout method and until recently the date has formatted just fine. Now, this grid, out of 15 total grids on the page, won't format the date. Except for one column name, all the grids are the same. I have included all the code below. I know we had 1 or 2 MS security udpates recently, but I would think that would effect all my grids, not just the one and I am having no luck tracking down the problem. I can't provide a data sample, but all the raw records have a proper sql date format of yyyy-mm-dd hh:mm:ss that I am formatting to MM/dd/yyyy. Thanks for any help you can provide.
Tryds = GetDataSet("loadMYDATA", Profile)If Not IsDatasetValid(ds) Thends = GetDataSet("emptyMYDATA")m_MYDATACount = 0ElselblMYDATACount.Text = ds.Tables(0).Rows.Countm_MYDATACount = ds.Tables(0).Rows.CountEnd IfigMYDATA.DataSource = dsigMYDATA.DataBind()Catch ex As ExceptionEnd Try
Protected Sub igMYDATA_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles igMYDATA.InitializeLayoutWith e.Layout.Bands(0).Columns.FromKey("ID").Header.Style.HorizontalAlign = HorizontalAlign.Center.CellStyle.HorizontalAlign = HorizontalAlign.Center.Hidden = TrueEnd WithWith e.Layout.Bands(0).Columns.FromKey("PROCESS").Header.Caption = "Process".Header.Style.HorizontalAlign = HorizontalAlign.Left.CellStyle.HorizontalAlign = HorizontalAlign.LeftEnd WithWith e.Layout.Bands(0).Columns.FromKey("MYDATA_NUMBER").Header.Caption = "MYDATA Number".Header.Style.HorizontalAlign = HorizontalAlign.Center.CellStyle.HorizontalAlign = HorizontalAlign.CenterEnd WithWith e.Layout.Bands(0).Columns.FromKey("ASSIGNED_OFFICE").Header.Caption = "Assigned To".Header.Style.HorizontalAlign = HorizontalAlign.Center.CellStyle.HorizontalAlign = HorizontalAlign.CenterEnd WithWith e.Layout.Bands(0).Columns.FromKey("DAYS_OPEN").Header.Caption = "Days Open".Header.Style.HorizontalAlign = HorizontalAlign.Center.CellStyle.HorizontalAlign = HorizontalAlign.CenterEnd WithWith e.Layout.Bands(0).Columns.FromKey("DUE_DATE").Header.Caption = "Due Date".Format = "MM/dd/yyyy".Header.Style.HorizontalAlign = HorizontalAlign.Center.CellStyle.HorizontalAlign = HorizontalAlign.CenterEnd WithWith e.Layout.Bands(0).Columns.FromKey("TYPE").Header.Style.HorizontalAlign = HorizontalAlign.Center.CellStyle.HorizontalAlign = HorizontalAlign.Center.Hidden = TrueEnd WithWith e.Layout.Bands(0).Columns.FromKey("INITIATION_DATE").Header.Caption = "Initiation Date".Format = "MM/dd/yyyy".Header.Style.HorizontalAlign = HorizontalAlign.Center.CellStyle.HorizontalAlign = HorizontalAlign.Center.Hidden = TrueEnd WithEnd Sub
<igtbl:UltraWebGrid ID="igMYDATA" runat="server" DisplayLayout-AutoGenerateColumns="true"EnableAppStyling="True" StyleSetName="Office2007Blue" StyleSetPath="~/ig_res/"DisplayLayout-CellPaddingDefault="5" DisplayLayout-Pager-AllowPaging="true" DisplayLayout-Pager-PageSize="100"DisplayLayout-Pager-PagerAppearance="Both" Height="350px" Width="100%" DisplayLayout-AllowSortingDefault="Yes"><Bands><igtbl:UltraGridBand><AddNewRow View="NotSet" Visible="NotSet"></AddNewRow></igtbl:UltraGridBand></Bands><DisplayLayout BorderCollapseDefault="Separate" CellPaddingDefault="5" Name="igMYDATA"RowHeightDefault="20px" Version="4.00" HeaderClickActionDefault="SortSingle"><FrameStyle></FrameStyle><Pager Alignment="Left" AllowPaging="True" PagerAppearance="Both" PageSize="100"QuickPages="3" StyleMode="Numeric" MinimumPagesForDisplay="2"><PagerStyle HorizontalAlign="Left" VerticalAlign="Middle" /><ComboStyle HorizontalAlign="Left" VerticalAlign="Middle"></ComboStyle></Pager><ActivationObject BorderColor="" BorderWidth=""></ActivationObject></DisplayLayout></igtbl:UltraWebGrid>
Thanks much Alex,
We are on the same page with what you sent, but it made no difference. However, here's what I've since discovered on this issue. Out of several dozen tables, this table was not originally created by my team. It is a table that is only used to import .xls formatted data. Apparently, data that is imported from .xls/csv format as all 255 char fields into a table with all sql columns defined as varchar(255). When I realized this I added the .DataType = "System.DateTime" on the line before .Format = "MM/dd/yyyy" and voila problem solved. I'm assuming that UltraWebGrid doesn't always see the string as a date, maybe due to the padding of extra spaces to fill the 255 char requirement, which I know shouldn't matter, but it sees something different about that field. But forcing the data type to be a date, fixed the issue.
Hello dbishop9,
I have created a sample based on your description and code. I have tested it with IE 8, 9 and Firefox and the date format in the grid is appearing as specified.
I am attaching this sample for your reference. Test it on your machine and feel free to modify it if it not exactly represents your scenario.
Thank you.