c# - 获取行 ID 然后将其存储在 session 中?

标签 c# asp.net session jqgrid

我对使用 JQGRID 有疑问。

然后如何获取jqgrid的行号
将其存储在 session 中。

谁能帮我解决这个问题?
我真的不知道我将如何开始创建它。
我刚开始使用 JQGrid 和 session

谢谢

这是我的代码。

function beforeSelect(rowid, e) {
                grid = $("#<%= jqgrid.ClientID %>");
                ItemID = grid.jqGrid('getCell', rowid, 'ItemID');
                var sessionItemID = '<%=Session["ItemID"] %>';
}

最佳答案

如果您的 rownumber 与 rowid 不同,您可以包含一个额外的字段来存储行号(就像您在代码中使用 itemId 一样)。否则,您将需要遍历网格以搜索特定的 rowid 并使用计数器来获取行号:

function getRowNumber(rowId) {


            var rownumber= 0;
            $('#gridId tbody tr').each(function (i, n) {
                var $row = $(n);

                    if($row.find('td:eq(0)').text()==rowId)//Assuming rowid is the first column of jqgrid(index=0). Otherwise change the index appropriately

                    { rownumber=i; }

            });
           return rownumber;
        }

关于c# - 获取行 ID 然后将其存储在 session 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16000294/

相关文章:

c# - ASP.NET (C#) : get value of a non-displayed field from a gridview selection

c# - 使用 GetHashCode 获取 Enum int 值

c# - 如何在 ASP.NET Core 6 中使用 Autofac/CaSTLe DynamicProxy 拦截器?

asp.net - 使用 Jquery 检查 URL 是否有效

UseCookieAuthentication 中的 ASP.NET Core Web 应用程序 ExpireTimeSpan 不起作用

session - 在自定义验证器、servicestack API 中隔离/访问设置 session 信息

c# - 在 C# 中对部分 SQL 进行 Lexing

asp.net - 自动创建 IIS 6.0 网站

跨 session 的 Powershell 作业?

php - 未定义的属性:CI::$session