专注于嵌套在具有固定高度和自动滚动的div中的一行gridview [英] Focus on a row of gridview nested in a div with fixed height and auto scroll

查看:111
本文介绍了专注于嵌套在具有固定高度和自动滚动的div中的一行gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网页上有一个嵌套在div中的gridview。 gridview有一个包含LinkBut​​ton的模板字段。单击LinkBut​​ton,RowCommand被触发,一些代码被执行,并有一个回发。我希望将焦点放在单击LinkBut​​ton的同一行上,以便用户可以轻松查看RowCommand所做的更改。



为此,我使用了以下代码位于aspx页面的第一行:

 <%@       语言  =  C#    AutoEventWireup   =  true    CodeFile   = 默认.aspx.cs   继承  =   _默认    MaintainScrollPositionOnPostback   =   true     %>  



在RowCommand中,我使用了以下代码:

< pre lang =c#> protected void GridView1_RowCommand( object sender,GridViewCommandEventArgs e)
{
// 要执行的代码
int row = int .Parse(e.CommandArgument.ToString()); // commandargument与行索引相同
GridView1.SelectedIndex = row;
GridView1.SelectedRow.Focus();
}



工作正常。

当我尝试修复gridview嵌套的div的高度时出现问题并将overflow-y设置为auto。 gridview线在这个区域滚动,select命令也可以工作但是它无法聚焦在选定的行上。



请帮助我使用代码来关注选定的行时div高度是固定的和gridview滚动。



我使用ASP.NET C#与sql server



谢谢你的帮助。

解决方案

在保持滚动位置的同时滚动网格视图 [ ^ ]


I have a gridview on my webpage nested in a div. The gridview has a template field containing a LinkButton. On click of LinkButton, RowCommand gets fired and some code is executed and there is a postback. I want the focus on same row in which LinkButton was clicked so that user can readily have a view of changes made by RowCommand.

To achieve this, I have used the following code on top line of aspx page:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MaintainScrollPositionOnPostback="true"  %>


In the RowCommand, I have used the following code:

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
            // code to be executed
           int row = int.Parse(e.CommandArgument.ToString()); // commandargument is same as row index
            GridView1.SelectedIndex = row;
            GridView1.SelectedRow.Focus();
    }


It works fine.
The problem comes when I try to fix the height of the div in which gridview is nested and set overflow-y to auto. The gridview lines scroll in this area, select command also works but it fails to focus on the selected row.

Kindly help me with code for focusing on the selected row when div height is fixed and gridview scrolls.

I am using ASP.NET C# with sql server

Thanks for your help.

解决方案

Scroll Gridview while Maintaining Scroll Position[^]


这篇关于专注于嵌套在具有固定高度和自动滚动的div中的一行gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆