radgrid with onitemdatabound

Dec 1, 2010 at 5:22 PM

I'm trying to figure out how i can use the radgrid onitemdatabound event with this but I don't know where to add the method that it calls. Is there a way to use it with <msxsl:script>? I'm just trying to change the cell color based on the number in the cell.

Thanks!

 

Coordinator
Dec 2, 2010 at 6:53 AM

Hello,

msxsl:script is not good Idea here. There are two ways of doing this.

  • Create a UserControl in ascx file using Visual Studio. After that you can deploy control and use XsltDb to put control on the page.
  • Inherit a custom class from RadGrid that implements your custom features

Example for method 2:

In the App_Code/YourCode put a c# file (review rules for App_Code):

 

namespace My
{
    public class MyGrid : Telerik.Web.UI.RadGrid
    {
        public MyGrid() : base()
        {
            this.ItemDataBound += new Telerik.Web.UI.GridItemEventHandler(MyGrid_ItemDataBound);
        }

        void MyGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            
        }
    }
}

 

 

In XsltDb module put config like following:

 

<xsl:text disable-output-escaping="yes"><![CDATA[
<%@ Register TagPrefix="my" NameSpace="My" %>
]]></xsl:text>

<mdo:asp xmlns:asp="asp" xmlns:telerik="telerik" xmlns:my="my">
      <asp:SqlDataSource
          id="dsModules"
          runat="server"
          ConnectionString="&lt;%$ ConnectionStrings:SiteSqlServer %&gt;"
          SelectCommand="SELECT ModuleName, FriendlyName, Description FROM dnn_DesktopModules"
      />
      <my:MyGrid
          ID="RadGrid1"
          DataSourceID="dsModules"
          AllowPaging="True"
          PageSize="10"
          runat="server">
      </my:MyGrid>
</mdo:asp>



















 

 

 

 

 

 

 

Dec 2, 2010 at 8:32 PM

Thanks! I went with option 2 and it works great. Thanks for all the work you put into this project, it's the best module I've used!