Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 无法发送数据库中的选定项目_Asp.net_Vb.net - Fatal编程技术网

Asp.net 无法发送数据库中的选定项目

Asp.net 无法发送数据库中的选定项目,asp.net,vb.net,Asp.net,Vb.net,我想发送数据库中的所有选定项,但不幸的是,第一个选定项没有保存其余项 <asp:DropDownList runat="server" ID="ddEVNT3" CssClass="form-control" SelectionMode="multiple" placeholder="Events"> <asp:ListItem Text="--Select Event--" Value="-1"></asp:ListItem> <asp:ListIt

我想发送数据库中的所有选定项,但不幸的是,第一个选定项没有保存其余项

 <asp:DropDownList runat="server" ID="ddEVNT3" CssClass="form-control" SelectionMode="multiple" placeholder="Events">
<asp:ListItem Text="--Select Event--" Value="-1"></asp:ListItem>
<asp:ListItem Text="50 m flat race for Boys"></asp:ListItem>
 <asp:ListItem Text="Musical Chair"></asp:ListItem>
 <asp:ListItem Text="Tug-of-war"></asp:ListItem>
<asp:ListItem Text="Penalty Shoot out"></asp:ListItem>
<asp:ListItem Text="Go as you like"></asp:ListItem>
 </asp:DropDownList>

我希望这能解决你的问题

Dim evt As String=“”
Dim li作为列表项
对于ddEVNT3.项中的每个li
如果选择了李,那么
evt+=li.值+“,”;
如果结束

接下来

此代码不会将任何内容保存到数据库中。请尝试在发布不起作用的代码时编写一个日志。我想将每个选定项存储在evt变量中…只有1个值正在拾取,但从下一个值开始,它不会进入循环。
Dim li As ListItem
 Dim evt As String = ""
   For Each li In ddEVNT2.Items
      If li.Selected Then
                    If evt = "" Then
                        evt = li.Value
                    Else
                        evt = evt & ", " & li.Value
                    End If
         End If
     Next