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
35
ITemplate databinding...
posted

I am writing web parts for MOSS 2007.  I am having trouble with the DataBinding at runtime.   What normally works with gridviews doesn't seem to work with the UltraGridView.

 Code works for GridViews:

void lbl_birthdate_DataBinding(object sender, EventArgs e)

{

System.Web.UI.WebControls.
Label l = (System.Web.UI.WebControls.Label)sender;

GridViewRow row = (GridViewRow)l.NamingContainer;

l.Text = DataBinder.Eval(row.DataItem, "BIRTHDATE", "{0:MM/dd}").ToString();

}

 

Code i'm trying in UltraGridView (which doesn't work):

void lbl_userID_DataBinding(object sender, EventArgs e)

{

System.Web.UI.WebControls.
Label l = (System.Web.UI.WebControls.Label)sender;

UltraGridRow row = ((CellItem)l.NamingContainer).Cell.Row;

l.Text = row.Band.Columns.FromKey("UserID").ToString();

}

 Any assistance would be greatly appreciated!

  • 35
    Verified Answer
    posted

    OK... A little re-thinking and i came up with this.  It always seems that the solution is easier than what i'm trying...

    This works in an ITemplate with UltraGridViews:

    void lbl_userID_DataBinding(object sender, EventArgs e)

    {

    System.Web.UI.WebControls.
    Label l = (System.Web.UI.WebControls.Label)sender;

    CellItem ci = (CellItem)l.NamingContainer;

    l.Text = DataBinder.Eval(ci.DataItem, "ColumnNameOfYourChoosing").ToString();

    }