Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3550
How to retreive the selected row.
posted

I need to work on the row that the client selected

I dont manage to get the selected row.

I try to use Behaviors.Selection.SelectedRows[0]

Behaviors.Selection.SelectedRows seems to be empty, even if the user chooses a row.

this is the code.

What should I do?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication3.WebForm2" %>

<%@ Register assembly="Infragistics4.Web.v11.2, Version=11.2.20112.1019, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.GridControls" tagprefix="ig" %>
<%@ Register assembly="Infragistics4.Web.v11.2, Version=11.2.20112.1019, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI" tagprefix="ig" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <ig:WebScriptManager ID="WebScriptManager1" runat="server">
    </ig:WebScriptManager>
    <div>
   
    </div>
    <ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px"   ViewStateMode="Enabled" EnableDataViewState="True">
                    <Behaviors>
                        <ig:RowSelectors>
                        </ig:RowSelectors>
                        <ig:Selection>
                        </ig:Selection>
                    </Behaviors>
                </ig:WebDataGrid>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Infragistics.Web.UI.GridControls;

namespace WebApplication3
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<string> ls = new List<string>();
            ls.Add("hello");
            WebDataGrid1.DataSource = ls;
            WebDataGrid1.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            GridRecord selectedRow = WebDataGrid1.Behaviors.Selection.SelectedRows[0];
        }
    }
}

Parents
No Data
Reply
  • 25665
    Offline posted

    Hello drpoalim,

    Looking at the markup you have provided it appears as though you don’t have row selection enabled properly. By default when you enable the selection behavior it is set to do cell selection. To set it to use row selection in the markup your code should look like:

    <ig:Selection CellClickAction="Row" RowSelectType="Single">

    </ig:Selection>


    With the CellClickAction property set to ‘Row and RoeSelectType set to “Single” or “Multiple” you will be able to view the selected rows using your current code.

    Please let me know if you have any questions concerning this matter.

    Sincerely,
    Mike P.
    Developer Support Engineer
    Infragistics, Inc.
    www.infragistics.com

Children