确定oninit事件中用于动态列创建的DDL值 [英] Determine DDL value for dynamic column creation in oninit event

查看:67
本文介绍了确定oninit事件中用于动态列创建的DDL值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,希望对这个复杂的问题有一个简单的解决方案。请纠正我一路上遇到的任何误解。
不久前,我写了一个具有动态列功能的GrivView。这些列将添加到OnInit页面事件中,以便在应用viewstate之前添加它们。在页面此部分的每个发布中都会重新应用它们,以便在应用viewstate时,可以维护用户已进行但未提交给数据库的更改。如果您不希望视图状态控制树失去同步并炸毁所有内容,那么这也是必需的。

Greetings, hopefully there is a simple solution for this complex problem. Please correct any misconceptions I have along the way. A while ago I wrote a GrivView with dynamic column capability. The columns are added in the OnInit page event so that they are added BEFORE the viewstate is applied. They are reapplied on every posting in this section of the page so that when the viewstate is applied changes that the user has made and not committed to the database are maintained. It also is required if you don’t want your viewstate control tree to get out of synch and blow everything up.

我当前的问题是我现在的任务是本质上是相同的,但基于下拉列表的列将有所不同(如果ddl发生更改,我将重新创建GridView,并且用户将丢失所有工作并显示警告)。如何获取OnInit事件的下拉列表中选择的ID?我的理解是,当用户在客户端上更改ddl的值时,会触发JavaScript __ doPostBack调用。然后将页面请求发送到服务器,但是到事件处理程序中出现新值时,我已经超过了需要添加列的位置。

My current problem is that I am now tasked with doing essentially the same thing where the columns will be different based on a Drop Down List (I will recreate the GridView if the ddl changes, and the users will lose all work with a warning). How can I get the ID that is selected in the Drop Down List in the OnInit Event? My understanding is that when the user changes the value of the ddl on the client side a JavaScript "__doPostBack" call is fired. The page request is then sent to the server but by the time the new value is present in the event handler I am past the point where I need to add the columns.

当人们试图确定什么控件导致回发时,我看到了一些我认为是有前途的东西,但是该代码依赖page.Request.Params.Get( __ EVENTTARGET );和page.Request.Form为空。

I saw something I thought was promising when people were trying to determine what control caused a post back but that code relies on page.Request.Params.Get("__EVENTTARGET"); and page.Request.Form which are empty.

我应该看看会话状态,尝试使用客户端操作或其他方法发送 ID(也许是偷偷摸摸地查看我丢失的viewstate的方法)?

Should I look at the session state, try to ‘send’ the ID using client side manipulation, or some other method (Perhaps a sneaky way to look in the viewstate I am missing)?

感谢任何想法!

推荐答案

即使您的表单似乎尚未重构,也可以从Request []集合中获得控件的提交值。

A control's submitted value is available from the Request[] collection even if it appears that your form has not been reconstructed yet.

您应该可以使用以下命令简单地在Init()中获取选定的值:

You should simply be able to get the selected value during Init() using the following:

string value = Request["myDropDownID"];

这篇关于确定oninit事件中用于动态列创建的DDL值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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