Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
125
Webdatetimeedit in Ultrawebgrid
posted

Dear Friends,

 I m using a Webdatetimeedit in Ultrawebgrid column.

For this column i have set the datatype as System.Datetime and Format as dd/MM/yyyy.

My Ultrawebgrid has add row button(AddnewBox) which  adds the new row to Ultrawebgrid

And for the Webdatetimeedit I have set the following properties

<igtxt:webdatetimeedit id="WebDateTimeEdit1" runat="server" Width="106px" EditModeFormat="dd/MM/yyyy " DisplayModeFormat="dd/MM/yyyy"></igtxt:webdatetimeedit>

On Pageload event I don't have any row in my ultrawebgrid.So user can add the row using add button.After adding row When i edit the Column and set the date as "01/01/2010" in the cell it ( it shows me the Proper value of cell as "01/01/2010") saves the Date but when

I edit the column and set the date as "25/01/2010" in the cell it gives me the error because at runtime it shows me the value of cell as nothing instead of "25/01/2010" 

 

Parents
No Data
Reply
  • 24497
    posted

    Hi,

    I tested sample where grid has no rows, has addNewButton and editor with dd/MM/yyyy. It worked ok and picked up value of date, persisted it, could edit cell after a postback after after editing new row or cell in existing row.

    If grid has custom editor, then there is no need to set Format of column.
    Maybe after a postback something happens to grid settings: column editor is lost or cell value is in wrong format. Try to experiment with simplest possible application (grid and editor on form and only initialization codes for grid and its editor) and test if it works correctly.

    I had codes as below.

    aspx:

    <igtxt:WebDateTimeEdit ID="WebDateTimeEdit1" runat="server" EditModeFormat="dd/MM/yyyy">
    </igtxt:WebDateTimeEdit>
    <igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" OnInitializeLayout="UltraWebGrid1_InitializeLayout" ... >
           <displaylayout ... AllowAddNewDefault="Yes">
        ...

    aspx.cs:

    protected override void OnInit(EventArgs e)
    {
      base.OnInit(e);
      this.UltraWebGrid1.InitializeDataSource += new Infragistics.WebUI.UltraWebGrid.InitializeDataSourceEventHandler(UltraWebGrid1_InitializeDataSource);
    }

    void UltraWebGrid1_InitializeDataSource(object sender, Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs e)
    {
      DataTable dt = new DataTable("Customer");
      dt.Columns.Add("CustomerID", typeof(int));
      dt.Columns.Add("CustomerName", typeof(string));
      dt.Columns.Add("Address", typeof(string));
      dt.Columns.Add("Date", typeof(DateTime));
      this.UltraWebGrid1.DataSource = dt;
    }
    protected void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
    {
      this.UltraWebGrid1.Columns[3].EditorControlID = this.WebDateTimeEdit1.UniqueID;
      this.UltraWebGrid1.Columns[3].Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Custom;
    }

Children