Hi,
I have a little problem, I need to access to each row of the Grid because I need to change the background color of the row depending of the register. In the native Control of Visual Studio is like this:
foreach(GridViewRow row in GridView1.Rows){
row[i] = ….
}
I tried to find a method but I couldn’t, please help me if you know the answer.
Thanks.
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> <ej:Grid ID="OrdersGrid" runat="server" AllowPaging="true" > <ClientSideEvents RowDataBound="rowDataBound" /> . . . . . . </ej:Grid> <script type="text/javascript"> function rowDataBound(args) { if (args.data.EmployeeID % 3 == 0) args.row.css("backgroundColor", "yellow").css("color", "red");/*custom css applied to the row */ } </script> |
Site.Master
<%--Enable PagerMethods--%>
<asp:ScriptManager runat="server" EnablePageMethods="true">
</asp:ScriptManager>
Default.aspx
<ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" AllowPaging="True">
<ClientSideEvents RowDataBound="rowDataBound" /> . . . . </ej:Grid> <script type="text/javascript">
function rowDataBound(args) {
//PageMethods object to call the WebMethod of the page.
PageMethods.OnRowDataBound(args.data); //passing the required parameters to the server side method
}
</script>
Default.aspx.cs [WebMethod]
public static void OnRowDataBound(object sender)
{
//code to perform custom operation
} |