DropDownList的问题,数据没有办法更新,马上给分 ListMonth.SelectItems[ListMonth.SelectIndex].Value 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ListMonth.SelectedIndex.value=clock.CurrentTime.Month;(初始的值) ListMonth.Items.FindByText(DateTime.Now.Month.ToString()).Selected=true; 在DropDownList的selcetedindex_changed事件中写入你想要的代码 再dropdownlist的SelectedIndexChanged事件里添加:int month=int.Parse(ListMonth.SelectedItem.Text);SqlCommand cmd=new SqlCommand("updMonth",cn);cmd.CommandType=CommandType.StoredProcedure;cn.Open();SqlParameter param=cmd.Parameters.Add("@Month");param["@Month"].Value=month;param=cmd.Parameters.Add("@ID");param["@ID"].Value=intID;//数据库相应字段IDcmd.ExecuteNonQuery();cn.Close();存储过程写法:Create Procedure updMonth(@ID int, @Month int)asUpdate table Set Month=@Month where ID=@ID DropDownList的属性enableviewstate设置成true 还有我有很多的DropDownListBox年月日时分 五个 你的DropDwonList是数据库绑定还是直接在控件里设置的?ListMonth.SelectedIndex=clock.CurrentTime.Month;SelectIndex应该是0,1,2,.....,没有选中的是-1 DropDownList控件有一个AutoPostBack属性,你将它设成True就可以执行它的SelectedIndexChanged事件了,不设这个属性是不行的。 谢谢上面的回答我的意思是把年月日时分五个都做成dropdownlist首先是显示出数据库中一个datetime然后再把更改后的转化为datetime后更新到数据库如果每个DropDownList都这么用SelectedIndexChanged很麻烦阿 在VS2008中打开.ascx文件,运行就报错? 网页上怎样弹出一个窗体???? xphome版如何构架.net环境[请指点] 帮我看看这段代码什么意思啊 asp.net 显示交叉数据 父子关系的表格在Repeater中的问题 请问水晶报表的控件,我为什么在工具箱里面找不到水晶报表控件呢? 菜鸟求高手指教一段代码意思 服务器应用程序不可用(asp.net) 求精通ASP程序设计会员系统 供求系统的朋友发邮件给我 ***高分求教!快来救命!(菜鸟问题)****** (philins ) 关于用ASP.NET编写网页的问题。
int month=int.Parse(ListMonth.SelectedItem.Text);
SqlCommand cmd=new SqlCommand("updMonth",cn);
cmd.CommandType=CommandType.StoredProcedure;
cn.Open();
SqlParameter param=cmd.Parameters.Add("@Month");
param["@Month"].Value=month;
param=cmd.Parameters.Add("@ID");
param["@ID"].Value=intID;//数据库相应字段ID
cmd.ExecuteNonQuery();
cn.Close();
存储过程写法:
Create Procedure updMonth
(@ID int,
@Month int)
as
Update table Set Month=@Month where ID=@ID
年月日时分 五个
首先是显示出数据库中一个datetime
然后再把更改后的转化为datetime后更新到数据库
如果每个DropDownList都这么用SelectedIndexChanged很麻烦阿