in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Change color of Row after cell value, Itemdatabind doesn't seem to work (C#)

Last post 7/24/2007 8:12 AM by itzcoatl calva. 0 replies.
Page 1 of 1 (1 items)
Sort Posts:
Previous Next
  • 7/24/2007 8:12 AM

    Change color of Row after cell value, Itemdatabind doesn't seem to work (C#)

    Hi,

    We are trying to set the font color of a row depending on the field DueDate being "" or not 

    I have read plenty on the forums as well as on the help, and cannot get this to work..

    Control is:   DevExpress.Web.ASPxGrid  
    Datasource is: DataTable

    I have tried with the create and databind methods as follows (I have alternate them, combine them, etc..)

    Control propeties:
    Layout > DirectRender : True/False (tried both)

    Top section CS file:

    using

    DevExpress.Web.ASPxGrid;
    using System.Drawing;

    We tried calling the event using this 2 methods:

    On CS file

    private void InitializeComponent() {
    this.policyList.ItemDataBound += new DevExpress.Web.ASPxGrid.ItemEventHandler(this.policyList_ItemDataBound);
    this.policyList.ItemCreated += new DevExpress.Web.ASPxGrid.ItemEventHandler(this.policyList_ItemDataBound);

    OR straight on the aspx page

    OnItemCreated

    ="policyList_ItemDataBound"
    OnItemDataBound="policyList_ItemDataBound"

    This is the function to execute:

    protected void policyList_ItemDataBound(object sender, DevExpress.Web.ASPxGrid.ItemEventArgs e)
    {
    // CODE NEVER PASS THIS LINE 
    if (e.Item.ItemType == ItemType.Item || e.Item.ItemType ==ItemType.AlternatingItem)
    {
    string emptydate = (string)e.Item.DataControllerRow["DueDate"];
    if ("".Equals(emptydate))
      e.Item.ForeColor =
    Color.Orange;
    else
      e.Item.ForeColor = Color.Purple;
    }
    }

    Problem is that ItemType is never Item or Alternating, I only got types: Header, Space,SynchSpace, Status

    DataControllerRow is always ""

    I don't think this is required but just in case, here is the datatable structure

    DataTable

    myDT = new DataTable();
    myDT.Columns.Add(new DataColumn("CustomerInvoiceId", Type.GetType("System.String")));
    myDT.Columns.Add(
    new DataColumn("IssueDate", Type.GetType("System.String")));
    myDT.Columns.Add(
    new DataColumn("DueDate", Type.GetType("System.String")));
    myDT.Columns.Add(
    new DataColumn("CutomerName", Type.GetType("System.String")));
    myDT.Columns.Add(
    new DataColumn("CutomerTel", Type.GetType("System.String")));
    myDT.Columns.Add(
    new DataColumn("PolicyAmount", Type.GetType("System.String")));
    myDT.Columns.Add(
    new DataColumn("MoneyAmount", Type.GetType("System.String")));

    Then we create datarows, fill with info, and databind them like:

    policyList.DataSource = myDT;
    policyList.DataKeyField =

    "CustomerInvoiceId";
    policyList.DataBind();

     

    What am I missing???

    Filed under: , , ,
Page 1 of 1 (1 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED