We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

OnServerRowSelected - Get field value

Hi,

How can I get the value of a specific field from a selected row?

In asp.net GridView I'm able to do this :
int id = Convert.ToInt32(grvMapaAcao.SelectedRow.Cells[1].Text);

I searched for almost 2 hours in documentation and in the Syncfusion Examples but nothing.

Just this :
protected void DefaultEvents_OnServerRowSelected(object sender, GridEventArgs e)
{
   serverEvent.InnerHtml = serverEvent.InnerHtml + span + "rowSelected</span> event called</span><hr>";
}
Kind Regards

Henrique

3 Replies

BM Balaji Marimuthu Syncfusion Team April 29, 2015 01:25 PM UTC

Hi Marcelo,

Thanks for using Syncfusion Products.

Based on your requirement we have created a sample and the selectedrow index and the selected records values of specific field can be get by using the variable GridEventArgs e in Onserverrowselected event. Please refer the below code snippet.


protected void DefaultEvents_OnServerRowSelected(object sender, GridEventArgs e)

{

int selectedrowindex = Convert.ToInt32(e.Arguments["rowIndex"]);

int id;

Dictionary<string, object> data = e.Arguments["data"] as Dictionary<string, object>;

foreach (KeyValuePair<string, object> keyval in data)

{

if (keyval.Key == "EmployeeID")

{

id = Convert.ToInt32(keyval.Value);

serverEvent.InnerHtml = serverEvent.InnerHtml + span + id;

}

}
}


Please refer the sample for further assistance and the same can be downloaded from the following link.
Sample: http://www.syncfusion.com/downloads/support/forum/118965/Sample-1050810287.zip


We are working on the documentation task for Server side events for ASP.NET and it will be published online in our upcoming Volume release.

Please let us know if you have any queries.

Regards,
Balaji Marimuthu


HE Henrique April 29, 2015 01:47 PM UTC


Hi Balaji,

Sorry but I found the solution a few hours ago, after a several hours of research and is better than this solution.

Three rows of code, and still is too much :
Dictionary<String, object> rowGrid = new Dictionary<String, object>();
rowGrid = (Dictionary<String, object>)e.Arguments["data"];

int id = (int)rowGrid["id"];

Sorry, but we need something to simplify our job, and not to complicate.

The end result of Syncfusion Grid and other controls are fantastic, but the way to build them is difficult and complicated, not to mention that the documentation is incomplete.

Here's an example:
I am completing a 630-hour project, if I were to develop it 100% with Syncfusion controls, I would have to add around 200 hours due to the learning curve but even after knowing well the controls still believe it would have to add at least 80 more hours, that here in Brazil is to ask the customer does not approve the project. (laughs)

Regards

Henrique


BM Balaji Marimuthu Syncfusion Team April 30, 2015 11:37 AM UTC

Hi Marcelo,

Thanks for the update and suggestions.

We can get the selected record values by using the Dictionary key value pair only in the server side. We will consider your suggestions.

Please get back to us if you have any concerns.

Regards,
Balaji Marimuthu

Loader.
Live Chat Icon For mobile
Up arrow icon