AspxGridView default focused row

Zoltan Kochan picture Zoltan Kochan · Dec 10, 2010 · Viewed 9.1k times · Source

I have an AspxGridView in my project with AllowFocusedRow="True". Every time I load the page (with the table) the first row is focused. When I assign -1 to gvMain.FocusedRowIndex on server side (before the page loading) it doesn't help. But when I change the focused row index on client side:

                    Init="function() {
                    gvMain.SetFocusedRowIndex(-1);

then it loads the table with first row selected which then disappears. So I guess it is better to define it earlier. But how?

Answer

Zoltan Kochan picture Zoltan Kochan · Dec 17, 2010

The solution was the PreRender event:

protected void ASPxGridView1_PreRender(object sender, EventArgs e) {
        if(!IsPostBack)
            ASPxGridView1.FocusedRowIndex = -1;
    }