Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Grid > RADGrid & Data display UserCtrl;
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered RADGrid & Data display UserCtrl;

Feed from this thread
  • Sp avatar

    Posted on Jun 20, 2011 (permalink)

    Hello Guru's
    I have a RADGrid in which I have added a user control to display data which I am getting from a Entity Framework, I am stuck in a situation where I am able to get data into the user control using below code:
    <EditFormSettings UserControlName="~/UserControls/UserCtrlName.ascx"
    InsertCaption="Details" EditFormType="WebUserControl">                   
        <EditColumn UniqueName="EditCommandColumn1" >
        </EditColumn>
    </EditFormSettings>
    This is the code that I am currently using to display the data on my UserCtrl
    <td><asp:label id="Label12" Text='<%# DataBinder.Eval( Container, "DataItem.Name" ) %>'
    runat="server"></asp:label></td>

    Now I want to do some conditioning based on data I recieve from this data source like Label Border & Label Backcolor.

    Can some one please help me out with a new approach to jandle this or tell me a way to continue with what I am doing.

    Thanks in Advance.
    Regards
    SPTECH07
    Happy Sharepointing

  • Posted on Jun 21, 2011 (permalink)

    Hello Sp,

    Try the following code snippet in ItemDataBound event to access the Label control in edit form and set background color accordingly. Hope this helps.

    C#:
    protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
    {
             if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
           {
               UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
               Label lbl = (Label)userControl.FindControl("label");
               if (lbl.Text == "Name")
               {
                   lbl.Style[" background-color"] = "Red";
                   lbl.Style[" border-color"] = "Blue";
               }
           }
    }

    Thanks,
    Princy.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Grid > RADGrid & Data display UserCtrl;