问题如何将值从一个过程传递到另一个过程 [英] problem how to pass value from one procedure to another

查看:59
本文介绍了问题如何将值从一个过程传递到另一个过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在代码隐藏中创建了5个下拉列表。我想在表中插入他们的

选择值,方法是将字符串分隔为:>

我可以得到他们的选择值,但是当我想要的时候我会被卡住执行

插入。

错误是未声明名称dd (在行:selvalue = selvalue&

Session(" dd"& dd.id)&":"


任何想法怎么解决这个?

感谢您的帮助

Dan


Dim dd()作为DropDownList

Dim i As Integer


for i = 1 to 5

dd(i)= New DropDownList

dd(i) .ID = id''可以是任何东西

next


For each d As DropDownList in dds

AddHandler d.SelectedIndexChanged,地址已下降

下一页


受保护的子项下降(ByVal发送者为对象,ByVal e As System.EventArgs)

Dim dd As DropDownList = CType(发件人,DropDownList)

会话(" dd"& id)= dd.SelectedValue

结束子


Protected Sub submit_Click(ByVal sender As Object,ByVal e As

System.EventArgs)

Dim i As Integer

Dim selvalue As String

对于i = 1到5

selvalue = selvalue&会话(QUOT峰; dd" &安培; dd.id)& ":"

下一页

sql =" insert ....."

....


Hi,

I create 5 dropdownlist in code-behind. I want to insert their
selectedvalues in a table by making a string separated with ":"
I can get their selecedvalues but i''m stuck when i want to execute the
insert.
The error is "name dd is not declared" (in line: selvalue = selvalue &
Session("dd" & dd.id) & ":"

Any idea how to solve this?
Thanks for help
Dan

Dim dd() As DropDownList
Dim i As Integer

for i= 1 to 5
dd(i) = New DropDownList
dd(i).ID = id ''can be anything
next

For Each d As DropDownList In dds
AddHandler d.SelectedIndexChanged, AddressOf dropd
Next

Protected Sub dropd(ByVal sender As Object, ByVal e As System.EventArgs)
Dim dd As DropDownList = CType(sender, DropDownList)
Session("dd" & id) = dd.SelectedValue
End Sub

Protected Sub submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim i As Integer
Dim selvalue As String
For i = 1 To 5
selvalue = selvalue & Session("dd" & dd.id) & ":"
Next
sql="insert ....."
....


推荐答案

Dan,


我不知道其他的错误是什么是的,但在我的想法是dd(

dropdownList)未声明,在所有其他方法中,你从

发送者获得它或声明它新。


Cor


" Dan" < d@ny.nlschreef in bericht

news:Om ************** @ TK2MSFTNGP02.phx.gbl ...
Dan,

I don''t know what other errrors there can be, but in my idea is dd (the
dropdownList) not declared, in all other methods you are getting it from the
sender or declare it new.

Cor

"Dan" <d@ny.nlschreef in bericht
news:Om**************@TK2MSFTNGP02.phx.gbl...




我在代码隐藏中创建了5个下拉列表。我想在表中插入他们的

选择值,方法是将字符串分隔为:>

我可以得到他们的选择值,但是当我想要的时候我会被卡住执行

插入。

错误是未声明名称dd (在行:selvalue = selvalue&

Session(" dd"& dd.id)&":"


任何想法怎么解决这个?

感谢您的帮助

Dan


Dim dd()作为DropDownList

Dim i As Integer


for i = 1 to 5

dd(i)= New DropDownList

dd(i) .ID = id''可以是任何东西

next


For each d As DropDownList in dds

AddHandler d.SelectedIndexChanged,地址已下降

下一页


受保护的子项下降(ByVal发送者为对象,ByVal e As System.EventArgs)

Dim dd As DropDownList = CType(发件人,DropDownList)

会话(" dd"& id)= dd.SelectedValue

结束子


Protected Sub submit_Click(ByVal sender As Object,ByVal e As

System.EventArgs)

Dim i As Integer

Dim selvalue As String

对于i = 1到5

selvalue = selvalue& Sessi上(QUOT峰; dd" &安培; dd.id)& ":"

下一页

sql =" insert ....."

...

Hi,

I create 5 dropdownlist in code-behind. I want to insert their
selectedvalues in a table by making a string separated with ":"
I can get their selecedvalues but i''m stuck when i want to execute the
insert.
The error is "name dd is not declared" (in line: selvalue = selvalue &
Session("dd" & dd.id) & ":"

Any idea how to solve this?
Thanks for help
Dan

Dim dd() As DropDownList
Dim i As Integer

for i= 1 to 5
dd(i) = New DropDownList
dd(i).ID = id ''can be anything
next

For Each d As DropDownList In dds
AddHandler d.SelectedIndexChanged, AddressOf dropd
Next

Protected Sub dropd(ByVal sender As Object, ByVal e As System.EventArgs)
Dim dd As DropDownList = CType(sender, DropDownList)
Session("dd" & id) = dd.SelectedValue
End Sub

Protected Sub submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim i As Integer
Dim selvalue As String
For i = 1 To 5
selvalue = selvalue & Session("dd" & dd.id) & ":"
Next
sql="insert ....."
...


内联评论:


Dan写道:
Inline comments:

Dan wrote:




我在代码隐藏中创建了5个下拉列表。我想在表中插入他们的

选择值,方法是将字符串分隔为:>

我可以得到他们的选择值,但是当我想要的时候我会被卡住执行

插入。

错误是未声明名称dd (在行:selvalue = selvalue&

Session(" dd"& dd.id)&":"


任何想法如何解决这个问题?
Hi,

I create 5 dropdownlist in code-behind. I want to insert their
selectedvalues in a table by making a string separated with ":"
I can get their selecedvalues but i''m stuck when i want to execute the
insert.
The error is "name dd is not declared" (in line: selvalue = selvalue &
Session("dd" & dd.id) & ":"

Any idea how to solve this?


Dim dd()As DropDownList

Dim i As Integer

>
for i = 1 to 5

dd(i)= New DropDownList

dd(i).ID = id''可以是任何东西
下一个
Dim dd() As DropDownList
Dim i As Integer

for i= 1 to 5
dd(i) = New DropDownList
dd(i).ID = id ''can be anything
next



什么是id?它没有在任何地方声明,并且永远不会赋值。在每个

意义上这个词,它什么都没有。写点东西会更有意义

就好像

dd(i).ID = i

哪个将i的值分配给下拉列表的ID属性。

What is id? It is not declared anywhere, and is never assigned a value. In every
sense of the word, it is nothing. It would make more sense to write something
like
dd(i).ID = i
which would assign the value of i to the ID property of the dropdown.


受保护的子下拉(ByVal发送者为对象,ByVal e As

System.EventArgs)Dim dd As DropDownList = CType(sender,DropDownList)

Session(" dd" id)= dd.SelectedValue

End Sub
Protected Sub dropd(ByVal sender As Object, ByVal e As
System.EventArgs) Dim dd As DropDownList = CType(sender, DropDownList)
Session("dd" & id) = dd.SelectedValue
End Sub



再次,什么是id?它没有在任何地方声明,也从未被赋予价值。

从这个词的每个意义上讲,它都没有。写

会更有意义

Session(" dd"& dd.ID)= dd.SelectedValue

将所选值存储在会话变量中,名称为ddx,

其中x是下拉列表的ID属性的值,如

previous循环中所指定的上面。

Again, what is id? It is not declared anywhere, and is never assigned a value.
In every sense of the word, it is nothing. It would make more sense to write
something like
Session("dd" & dd.ID) = dd.SelectedValue
which would store the selected value in a session variable with the name ddx,
where x is the value of the ID property of the drop down, as assigned in the
previous loop above.


>

受保护的子提交_Click(ByVal发送者为对象,ByVal e As

System.EventArgs)

Dim i As Integer

Dim selvalue As String

for i = 1 to 5

selvalue = selvalue&会话(dd& dd.id)& ":"

下一页

sql =" insert ....."
>
Protected Sub submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim i As Integer
Dim selvalue As String
For i = 1 To 5
selvalue = selvalue & Session("dd" & dd.id) & ":"
Next
sql="insert ....."



这是更接近的,因为dd.id可能是试图获得

的ID属性下拉。不幸的是,dd本身从未被声明,并且从未被赋予

值,而这次它是dd什么都不是。写作更有意义

selvalue = selvalue&会话(dd& i)

将通过上面的

事件处理程序检索会话变量中存储的5个值中的每一个 - 如果所有五个都已设置。


将所有5到

的Session变量存储起来可能是一个好主意,以防其中一些永远不会被设置。第一个循环将是一个

适合这样做的地方。

This is closer, in that dd.id is presumably an attempt to get the ID property of
a drop down. Unfortunately, dd itself is never declared, and never assigned a
value, and this time it is dd that is nothing. It would make more sense to write
selvalue = selvalue & Session("dd" & i)
which will retrieve each of the 5 values stored in session variables by the
event handler above - if all five have been set.

It might be a good idea to store something in the Session variables for all 5 to
start with, in case some of them never get set. The first loop would be a
suitable place to do that.


感谢您的回复。

我想我的解释不够好。我省略了一些限制

消息的代码。


这是真正的问题:有一个未知数量的下拉列表

(调查问题)(我以5为例)取决于用户是谁b $ b创建问题。

下拉列表(有些不可见)具有属性AutoPostBack =

为真,因为dropdownlist x的值可以使另一个

下拉列表可见。因此,每次用户引入一个值时,依赖的

DD将是可见的或保持不可见。这已经解决了。


现在,我想收集所有选定值并将它们放入表中。

但是我找不到办法在提交

程序中传递收集的选定值。

朋友dds作为新列表(DropDownList)

....

Dim dd()As DropDownList


For i = 1 To(下拉列表的数量)

dd(i)= New DropDownList

dd(i).ID = id''id是表格中相关问题的ID

dd(i).AutoPostBack = True

''从桌子喂食

....

form1.Controls.Add(dd(i))

....


For each d As DropDownList in dds

AddHandler d.SelectedIndexChanged,AddressOf dropd

Next


受保护的Sub dropd(ByVal sender As Object,ByVal e As System.EventArgs)

Dim dd As DropDownList = CType(sender,DropDownList)

session(dd。 ID)= dd.selectedValue

End Sub


Protected Sub submit_Click(ByVal sender As Object,ByVal e As

System.EventArgs)

''如何获得selectvalue?

结束子


谢谢

Steve Gerrard < my ******** @ comcast.netschreef in bericht

news:p6 ********************** ********@comcast.com。 ..
Thanks for replying.
I think my explanation was not good enough. I ommitted some code to restrict
the message.

This is the real problem: there are a unknown number of dropdownlist
(questions of a survey) (i took 5 as example) depending of the user who
create the questions.
The dropdownlists (some are not visible) have the property AutoPostBack =
true, because the value of dropdownlist x can make another further
dropdownlist visible. So each time an user introduces a value, the depending
DD will be visible or remains unvisible. This is solved.

Now, i want to collect all the selectedvalues and put them into a table.
But i can''t find a way to pass the collected selectedvalues in the submit
procedure.
Friend dds As New List(Of DropDownList)
....
Dim dd() As DropDownList

For i = 1 To (number of dropdownlist)
dd(i) = New DropDownList
dd(i).ID = id ''id is the id of the related quesion in the table
dd(i).AutoPostBack = True
''fed from table
....
form1.Controls.Add(dd(i))
....

For Each d As DropDownList In dds
AddHandler d.SelectedIndexChanged, AddressOf dropd
Next

Protected Sub dropd(ByVal sender As Object, ByVal e As System.EventArgs)
Dim dd As DropDownList = CType(sender, DropDownList)
session(dd.ID)=dd.selectedValue
End Sub

Protected Sub submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
''how to get the selectvalue here?
End Sub

Thanks
"Steve Gerrard" <my********@comcast.netschreef in bericht
news:p6******************************@comcast.com. ..

内联评论:


Dan写道:
Inline comments:

Dan wrote:

>

我在代码隐藏中创建了5个下拉列表。我想通过将一个字符串分隔为:来将他们的
选择值插入表中。
我可以获得他们的选择值但是当我想执行
插入时我被卡住了。
错误是未声明名称dd (符合:selvalue = selvalue&
Session(" dd"& dd.id)&":"

任何想法如何解决这个问题?
>Hi,

I create 5 dropdownlist in code-behind. I want to insert their
selectedvalues in a table by making a string separated with ":"
I can get their selecedvalues but i''m stuck when i want to execute the
insert.
The error is "name dd is not declared" (in line: selvalue = selvalue &
Session("dd" & dd.id) & ":"

Any idea how to solve this?



> Dim dd()As DropDownList
Dim i As Integer

for i = 1 to 5
dd(i)=新DropDownList
dd(i).ID = id''可以是任何东西
下一个
>Dim dd() As DropDownList
Dim i As Integer

for i= 1 to 5
dd(i) = New DropDownList
dd(i).ID = id ''can be anything
next



什么是id?它没有在任何地方声明,并且永远不会赋值。在

的每个字的意义上,它都没有。写出更有意义

类似

dd(i).ID = i

将i的值赋给下拉列表的ID属性。


What is id? It is not declared anywhere, and is never assigned a value. In
every sense of the word, it is nothing. It would make more sense to write
something like
dd(i).ID = i
which would assign the value of i to the ID property of the dropdown.


>受保护的Sub dropd(ByVal sender As Object,ByVal e As / System.EventArgs)Dim dd As DropDownList = CType(sender,DropDownList)
Session (dd& id)= dd.SelectedValue
结束次级
>Protected Sub dropd(ByVal sender As Object, ByVal e As
System.EventArgs) Dim dd As DropDownList = CType(sender, DropDownList)
Session("dd" & id) = dd.SelectedValue
End Sub



再次,什么是id?它没有在任何地方声明,并且从未被赋予

值。在每个意义上,它都没有。写一些像

Session(" dd"& dd.ID)= dd.SelectedValue

这样会更有意义

将所选值存储在一个名为

ddx的会话变量中,其中x是下拉列表的ID属性的值,在前一个循环中分配为

上面。


Again, what is id? It is not declared anywhere, and is never assigned a
value. In every sense of the word, it is nothing. It would make more sense
to write something like
Session("dd" & dd.ID) = dd.SelectedValue
which would store the selected value in a session variable with the name
ddx, where x is the value of the ID property of the drop down, as assigned
in the previous loop above.


>>
受保护的子提交_Click(ByVal发送者为对象,ByVal e As
System.EventArgs)
Dim i As Integer
Dim selvalue As String
对于i = 1到5
selvalue = selvalue&会话(dd& dd.id)& ":"
下一页
sql =" insert ....."
>>
Protected Sub submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim i As Integer
Dim selvalue As String
For i = 1 To 5
selvalue = selvalue & Session("dd" & dd.id) & ":"
Next
sql="insert ....."



这是更接近的,因为dd.id可能是试图获得下拉的ID

属性。不幸的是,dd本身从未被声明,并且

从未分配过一个值,而这次它是dd什么都不是。它会更有意义地写作

selvalue = selvalue&会话(dd& i)

将检索会话变量中存储的5个值中的每个值,如上面的事件处理程序,如果所有五个都已设置。


将一些内容存储在会话变量中,这可能是个好主意,因为其中一些永远不会被设置。第一个循环

将是一个合适的地方。


This is closer, in that dd.id is presumably an attempt to get the ID
property of a drop down. Unfortunately, dd itself is never declared, and
never assigned a value, and this time it is dd that is nothing. It would
make more sense to write
selvalue = selvalue & Session("dd" & i)
which will retrieve each of the 5 values stored in session variables by
the event handler above - if all five have been set.

It might be a good idea to store something in the Session variables for
all 5 to start with, in case some of them never get set. The first loop
would be a suitable place to do that.



这篇关于问题如何将值从一个过程传递到另一个过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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