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];
        }
    }
}