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.
Unfortunately, activation email could not send to your email. Please try again.

Rows Select

Thread ID:

Created:

Updated:

Platform:

Replies:

124613 Jun 17,2016 03:53 AM Jun 22,2016 06:05 AM ASP.NET Web Forms 5
loading
Tags: Grid
Hrvoje Voda
Asked On June 17, 2016 03:53 AM

I would like to get values from selected row into textbox.

Gowthami V [Syncfusion]
Replied On June 20, 2016 08:33 AM

Hi Hrvoje, 
 
Thanks for contacting Syncfusion support. 
 
We can get the selected records using “getSelectedRecords” method in client side as follows, 
 
<ej:Grid ID="FlatGrid" runat="server" AllowSorting="True"> 
. . . .  
 
</ej:Grid> 
 
  <script type="text/javascript"> 
        $("#btn").ejButton({ 
            text: "set text value in client side", 
            click: function (args) { 
                var gridObj = $('#<%= FlatGrid.ClientID %>').ejGrid('instance'); 
                var d = gridObj.getSelectedRecords()[0]; 
                $("#txt").val(d.EmployeeID); 
            } 
        }); 
        </script> 
 
Please refer to the below link for more clarification about getSelectedRecords, 
 
 
If you need get the selected row details in RowSelected server side event then refer the below code example, 
 
  <ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" AllowPaging="True" OnServerRowSelected="FlatGrid_ServerRowSelected"> 
.  . . . 
protected void FlatGrid_ServerRowSelected(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); 
                    TextBox1.Text = id.ToString(); 
                } 
            } 
        } 
 
For your convenience we have created a sample and the same can be downloaded from the following link, 
 
 
If we misunderstood your requirement please provide us below details, 
 
1.       Share the detailed explanation of your requirement. 
2.       Screenshot of the requirement. 
 
The provided information will help to analyze the requirement and provide you the response as early as possible. 
 
Regards, 
 
Gowthami V. 


Hrvoje Voda
Replied On June 21, 2016 07:25 AM

This works fine, but I have grid as userControl.
So, I want to get values from Grid.SelectedIndex number...without knowing column name..
Is that possible?

Hrvoje Voda
Replied On June 21, 2016 07:53 AM

I found the solution.
All I need is to raise an event and send data dictionary values.

Hrvoje Voda
Replied On June 21, 2016 08:15 AM

There is only one problem.
After selected row grid is refreshing and return no data.
How can I prevent grid from refresh?
I put update panel but it doesn't work.

Gowthami V [Syncfusion]
Replied On June 22, 2016 06:05 AM

Hi Hrvoje, 
 
Query: After selected row grid is refreshing and return no data. 
 
We are able to reproduce the issue while bind the data to the grid under Page_Load method with checking condition as !IsPostBack as below, 
 
protected void Page_Load(object sender, EventArgs e) 
        { 
            if (!IsPostBack) {  
                this.FlatGrid.DataSource = OrderRepository.GetAllRecords().ToList(); 
                this.FlatGrid.DataBind(); 
            } 
             
             
        } 
 
While refreshing the page the !IsPostBack condition get failed and not set the data to the grid. So that only the grid rendered with no data. 
 
If you are facing same issue that data not bound while post back, then we can resolve the issue by set DataSourceCachingMode as “ViewState” or “Sessionwhich is used to cache data on page postback. 
 
Refer to the below code example, 
 
  <ej:Grid ID="FlatGrid" runat="server" DataSourceCachingMode="ViewState"> 
. . . . 
. . . . 
</ej:Grid> 
 
 
To avoid the page refresh while post back then we can render the grid inside update panel.  
 
We have created a sample based on your requirement and the same can be downloaded from the following link, 
 
 
Regards, 
 
Gowthami V. 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;