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
640
Neither RowSelectionChanged nor Selection.RowSelectionChanged is fired on PostBack
posted

Normal 0 false false false MicrosoftInternetExplorer4

Hello everyone, I met a problem trying to get selected row on postback

Scenario is pretty simple.
I create UpdatePanel and WebDataGrid in CreateChildControls

protected override void CreateChildControls()
{
    base.CreateChildControls();

    UpdatePanel container = new UpdatePanel{ ID = "c", ChildrenAsTriggers = true};
    this.Controls.Add(container);

    this.grid1 = new WebDataGrid
    {
        ID = "grid1",
        EnableAjax = false,
        EnableAjaxViewState = false,
        EnableViewState = false
    };

    container.ContentTemplateContainer.Controls.Add(this.grid1);

    this.grid1.Behaviors.Add(new Selection
    {
        RowSelectType = SelectType.Single,
        CellClickAction = CellClickAction.Row,
        Enabled = true
    });

    this.grid1.RowSelectionChanged += Selection_RowSelectionChanged;
    this.grid1.Behaviors.Selection.RowSelectionChanged += Selection_RowSelectionChanged;
    this.grid1.Behaviors.Selection.AutoPostBackFlags.RowSelectionChanged = true;
}

void Selection_RowSelectionChanged(object sender, SelectedRowEventArgs e)
{
    throw new NotImplementedException();
}

Then I add columns and populate grid with data from my dataset

protected void Page_Load(object sender, EventArgs e)
{
        DataSet ds = new DataSet();
        ds.ReadXml("c:\\q.xml", XmlReadMode.ReadSchema);

...    Add several columns here

        this.grid1.DataSource = ds;
        this.grid1.DataBind();
}

Postbacks occur correctly on every mouse click and selected row index is passed in grid1_clientState parameter (bold) [[null,[[[[[5]],[],null],[null,null],[null]],[[null,[],null],[{},[{}]],null],[[null,[],null],[{"1":[6,[{"index":1,"key":[1]}]]}

But none of RowSelectionChanged evens is fired.

Can anyone say what is wrong?
Is it affected by the time grid is populated with data? What is the right time to populate then?
Maybe some settings/options/flags are missing?

Version I'm using: 10.3 SR2120 for ASP.Net