- Home
- Forum
- ASP.NET Web Forms
- Accessing each row
Accessing each row
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.
Thanks for your interest in Syncfusion Products.
We are glad to let you know that we have an event “rowDataBound” in grid which is triggered every time a request is made to access any row information.
Please refer the below Class reference link for more information on the rowDataBound event.
Class Reference Link: http://help.syncfusion.com/UG/JS_CR/ejGrid.html#event:rowDataBound
For your convenience, we have created a simple sample and the sample can be downloaded from the below location.
Sample Link: http://www.syncfusion.com/downloads/support/forum/118987/Sample-1814495003.zip
In the above sample, we have changed the background color of the row depending on the data present in the row. Please refer the below code snippets.
<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> |
Please try the sample and get back to us if you need any further assistance.
Regards
Ragavee U S
|
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
} |
I was able to use queryCellInfo event and change the way the data binds to my grid.
Now I have a requirement where I need to open a popup on click of an unbound button
and in that popup I need TextBoxes that are bound with the records in the syncfusion gird row
so that I can update the fields on click of button in the popup.
Regards
Avishake Attari
- 8 Replies
- 4 Participants
-
JU Julio
- May 1, 2015 02:56 PM UTC
- Oct 26, 2016 10:37 AM UTC