开发者

AspxGridView default focused row

开发者 https://www.devze.com 2023-01-30 02:33 出处:网络
I have an AspxGridView in my project with AllowFocusedRow=\"True\". Eve开发者_运维技巧ry time I load the page (with the table) the first row is focused. When I assign -1 to gvMain.FocusedRowIndex on s

I have an AspxGridView in my project with AllowFocusedRow="True". Eve开发者_运维技巧ry 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?


The solution was the PreRender event:

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


Use the ASPxGridView's DataBound event as shown below to hide the FocusedRow:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号