从字符串 到类型 Double 的转换无效

wubaotong 2010-02-02 12:38:49
sql语句:
Dim txtchexing As DropDownList
txtchexing=e.Item.Cells(8).Controls(0)
Dim strSql As String
strSql="Update car Set 车号='" & txtnm.Text & "',始发站='" & txtshifa.Text & "',终点站='" & txtzhongdian.Text & "',开车时间='" & txtkaiche.Text & "',到达时间='" & txtdaoda.Text & "',座位数='" & txtzuowei.Text & "',车型=" & cstr(txtchexing.SelectedItem.text) & " Where 编号=" & MyDataGrid.DataKeys(CInt(E.Item.ItemIndex))
用的是datagrid自定义列
<asp:TemplateColumn HeaderText="车型" >
<ItemTemplate>
<asp:label Text='<%# Container.DataItem("车型") %>' runat="server"/>
</ItemTemplate>
<EditItemTemplate>
<asp:dropdownlist id="theGrade" SelectedIndex='<%# Container.DataItem("车型")-1 %>' runat="server">
<asp:listitem >豪华卧铺</asp:listitem>
<asp:listitem >长途大巴</asp:listitem>
<asp:listitem >中型客车</asp:listitem>
<asp:listitem >中巴</asp:listitem>
<asp:listitem >小型客车</asp:listitem>
</asp:dropdownlist >
</EditItemTemplate>
</asp:TemplateColumn>
帮帮忙呀
...全文
1098 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
csuchen6 2012-06-26
  • 打赏
  • 举报
回复
都改成String就好啦
足球中国 2010-02-02
  • 打赏
  • 举报
回复
当然不能转。要根据选择的id
wubaotong 2010-02-02
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 chen_ya_ping 的回复:]
引用 2 楼 wubaotong 的回复:
测试的时候提示 从字符串“豪华卧铺”到类型“Double”的转换无效。

请问,你自己想想这个可以转换吗?
[/Quote]
我知道肯定不能用,但不知道怎么转化好,所以来求救了。
chen_ya_ping 2010-02-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wubaotong 的回复:]
测试的时候提示 从字符串“豪华卧铺”到类型“Double”的转换无效。
[/Quote]
请问,你自己想想这个可以转换吗?
wubaotong 2010-02-02
  • 打赏
  • 举报
回复
测试的时候提示 从字符串“豪华卧铺”到类型“Double”的转换无效。
xupeihuagudulei 2010-02-02
  • 打赏
  • 举报
回复
哪个地方报错?
不懂vb
看着好累
夏脑 2010-02-02
  • 打赏
  • 举报
回复
就改为SelectedItem=' <%# Container.DataItem("车型")%>'
想想这里能计算减法吗?<%# Container.DataItem("车型")-1 %>
xray2005 2010-02-02
  • 打赏
  • 举报
回复
改为:
<asp:dropdownlist id="theGrade" SelectedIndex=' <%# Container.DataItem("车型")-1 %>' runat="server">
<asp:listitem Value=1 Text="豪华卧铺"/>
<asp:listitem Value=2 Text="长途大巴"/>
<asp:listitem Value=3 Text="中型客车"/>
<asp:listitem Value=4 Text="中巴"/>
<asp:listitem Value=5 Text="小型客车"/>
</asp:dropdownlist >

还有:
车型=" & cstr(txtchexing.SelectedItem.text)

改为:
车型=" & cstr(txtchexing.SelectedItem.Value)
wangchunyan2008 2010-02-02
  • 打赏
  • 举报
回复
文本类型怎么能转换为Double型呢,要么你村数据库的时候,存listitem的ID
丰云 2010-02-02
  • 打赏
  • 举报
回复
既然车型文本类型的,就直接赋值
车型=" & txtchexing.SelectedItem.text & "
丰云 2010-02-02
  • 打赏
  • 举报
回复
cstr(txtchexing.SelectedItem.text)
是什么意思?
wubaotong 2010-02-02
  • 打赏
  • 举报
回复
用的是acess数据库,没有人回答吗?
wubaotong 2010-02-02
  • 打赏
  • 举报
回复
车型是文本类型的
wubaotong 2010-02-02
  • 打赏
  • 举报
回复
没有人回答吗,快救救我吧!

62,264

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧