Problem RadGrid in a RadMenu (Need Help Urgent)?

3 posts, 1 answers
  1. Bhuvan
    Bhuvan avatar
    50 posts
    Member since:
    Dec 2010

    Posted 07 Jan 2011 Link to this post

    Hi Team,


    I had a RadMenu which consists of RadGrid Like this

    <Code>

    <telerik:RadMenu runat="server" ID="RadMenu1">
    <Items>
        <telerik:RadMenuItem Text=" Commitment">
           <Items>
          <telerik:RadMenuItem Width="785">
          <ItemTemplate>
                             <telerik:RadGrid ID="RG_FinalizeChoices" runat="server" DataSourceID="SDS_DataBaseID" Width="750" AutoGenerateColumns="false">
                               <MasterTableView>
                                        <Columns>
                                            <telerik:GridTemplateColumn HeaderText="Step">
                                                <ItemTemplate>                    
                                                  <asp:LinkButton ID="lbtn_Progress" runat="server" Text='<%# Eval("statusname") %>'></asp:LinkButton>                                             
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn HeaderText="Progress">
                                                <ItemTemplate>                    
                                                 <cc1:ProgressBar ID="pb_Studentstatus" runat="server" Percentage='<%# Eval("Progress") %>' Width="10px" Height="10px"/>                                                 
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn HeaderText="StudentsStatus">
                                                <ItemTemplate>                    
                                                    <asp:Label ID="lbl_date" runat="server" Text='<%# Eval("StudentsStatus") %>'></asp:Label>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>                                        
                                        </Columns>                                            
                                    </MasterTableView>            
                            </telerik:RadGrid>
          </ItemTemplate>
          </telerik:RadMenuItem>  
          </Items>
        </telerik:RadMenuItem>
        
        I need to Conditionally format my RadGrid Columns

    I am attaching a pic here....In the pic
    the Row which is ATV should be in Red and the rest other two should be in other colors...Is it Possible


    Regards
    Bhuvan

  2. Bhuvan
    Bhuvan avatar
    50 posts
    Member since:
    Dec 2010

    Posted 07 Jan 2011 Link to this post

    Trail Pic
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Veli
    Admin
    Veli avatar
    2002 posts

    Posted 13 Jan 2011 Link to this post

    Hi Bhuvan,

    You can use RadGrid's ItemCreated event. This event fires for every item in RadGrid. Inside the event handler, you can check if your item is of type GridDataItem and apply a CSS class to it:

    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem dataItem = (GridDataItem)e.Item;
                 
            //if this is the first item
            if (dataItem.ItemIndex == 0)
            {
                dataItem.Style["background-color"] = "red";
            }
        }
    }

    Alternatively, if you do not now which position is your item you need to style at, but you know the item's data key value (e.g. StudentStatus is your data key and you know ATV is the item you are looking for), you can take an alternative approach. You can use RadGrid's or Page's PreRender event like follows:

    protected void Page_PreRender(object sender, EventArgs e)
    {
        GridDataItem dataItem = RadGrid1.MasterTableView.FindItemByKeyValue("StudentStatus", "ATV");
        dataItem.Style["background-color"] = "red";
    }


    Veli
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top