求助:类型转换--我传上来了冰镇柠檬汁儿
院系ID DropDownList1
院系名称DropDownList2
<asp:DropDownList ID="DropDownList1" runat="server" Width="131px" DataSourceID="SqlDataSource1" DataTextField="dept_ID" DataValueField="dept_ID"></asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:labConnectionString %>"SelectCommand="SELECT [dept_ID] FROM[lab_dept]"></asp:SqlDataSource>//这个绑定成功了
<asp:DropDownList ID="DropDownList2" runat="server" Width="131px" DataSourceID="SqlDataSource2" DataTextField="dept_name" DataValueField="dept_name"></asp:DropDownList>
//SqlDataSource2的SelectCommand是这么写的
select dept_name from lab_dept where dept_ID='"+int.Parse(DropDownList1.Text)+"'
但报错,说类型无法转换
在数据库中,dept_ID是int
[此贴子已经被作者于2007-4-2 9:55:27编辑过]