动态创建的单选按钮列表
有一个母版页。内容页面有一个包含请求变量的超链接列表。您单击其中一个链接即可转到包含单选按钮列表的页面(也许)。
第一个问题:当我到达新页面时,我使用其中一个变量来确定是否将单选按钮列表添加到页面上的占位符中。我尝试在 page)_load 中执行此操作,但无法获取所选值。当我在 preInit 中尝试执行此操作时,页面第一次出现时,我无法访问页面的控件。 (对象引用未设置为对象的实例。)我认为这与 MasterPage 和页面内容有关?控件要稍后才实例化? (顺便使用VB)
第二个问题:假设我让它工作,一旦我点击一个按钮,我仍然可以访问传递的请求变量来确定单选按钮列表中的选定项目吗?
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
'get sessions for concurrent
Dim Master As New MasterPage
Master = Me.Master
Dim myContent As ContentPlaceHolder = CType(Page.Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder)
If Request("str") = "1" Then
Dim myList As dsSql = New dsSql() ''''instantiate the function to get dataset
Dim ds As New Data.DataSet
ds = myList.dsConSessionTimes(Request("eid"))
If ds.Tables("conSessionTimes").Rows.Count > 0 Then
Dim conY As Integer = 1
CType(myContent.FindControl("lblSidCount"), Label).Text = ds.Tables("conSessionTimes").Rows.Count.ToString
抱歉,我是如此需要帮助 - 但也许有人可以引导我到带有示例的页面?也许看到它会有助于理解它?
谢谢....JB
Have a master page. The content page has a list with hyperlinks containing request variables. You click on one of the links to go to the page containing the radiobuttonlist (maybe).
First problem: When I get to the new page, I use one of the variables to determine whether to add a radiobuttonlist to a placeholder on the page. I tried to do it in page)_load but then couldn't get the values selected. When I played around doing it in preInit, the first time the page is there, I can't get to the page's controls. (Object reference not set to an instance of an object.) I think it has something to do with the MasterPage and page content? The controls aren't instantiated until later? (using vb by the way)
Second problem: Say I get that to work, once I hit a button, can I still access the passed request variable to determine the selected item in the radiobuttonlist?
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
'get sessions for concurrent
Dim Master As New MasterPage
Master = Me.Master
Dim myContent As ContentPlaceHolder = CType(Page.Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder)
If Request("str") = "1" Then
Dim myList As dsSql = New dsSql() ''''instantiate the function to get dataset
Dim ds As New Data.DataSet
ds = myList.dsConSessionTimes(Request("eid"))
If ds.Tables("conSessionTimes").Rows.Count > 0 Then
Dim conY As Integer = 1
CType(myContent.FindControl("lblSidCount"), Label).Text = ds.Tables("conSessionTimes").Rows.Count.ToString
Sorry to be so needy - but maybe someone could direct me to a page with examples? Maybe seeing it would help it make sense?
Thanks....JB
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有内容占位符,您可以将单选按钮列表控件添加到那里吗?
在主页上:
一些链接,包含下一页使用的请求变量。
现在,在带有单选按钮列表的页面上,将其添加到内容占位符中。
单选按钮列表.aspx:
根据传入的信息动态填充单选按钮列表的代码。
希望您能在这里找到有用的内容。
If you have a content placeholder, could you just add the radio button list control to there?
On Master Page:
Some links, containing request variables used on the next page.
Now on the page with the radio button list, add it into the content placeholder.
RadioButtonList.aspx:
Code to dynamically populate your radio button list based on the information passed in.
Hopefully you'll find something helpful in here.