使用下拉列表的值更新单个记录 [英] Update single record with value of dropdown list
问题描述
大家好吧
i有一个与sqldatasource相关的下拉列表
并填写一些房间代码
i想要
当用户选择其中一个代码并单击确定
这应该发生:
找到具有St_Code = session [stcode]的记录//它让我们想要得到房间吗?
然后当它创建设置或更新列Room_Code的那条记录下拉选择项目
它真的很简单的说法: D
我该怎么办?如果你需要查看我的代码,我会发送它,但我不确定是否需要它!
i只想用下拉列表的值更新单个记录
以获得更多理解
ST_CODE =学生代码,即学生注册号码
和ROOM_CODE =学生房间代码,表示学生注册的空间
我尝试了什么:
什么都不知道,我还没有尝试任何东西
,这是我刚才连接到数据库的下拉代码
hi all
i have a drop down list connected with sqldatasource
and fill with some "Room Code"
i want
when user select one of these code's and click on Ok
this should happen:
find the record that has St_Code = session["stcode"] //its get us who want to get the room?
then when it founded set or update column Room_Code of that record to dropdown selected item
its really simple way to say it :D
what should i do ? if you need to see my codes i will send it but im not sure need it!
i just want to update a single record with the value of dropdown list
for more understanding
ST_CODE = Student Code that means student registered number
and ROOM_CODE = Student room code that means wich room for wich student registred
What I have tried:
nothing know and i've not trying any thing yet
and here is my dropdown code i just connected to the database
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseConnectionString1"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
推荐答案
在下拉列表的OnSelectedIndexChanged事件上写一个参数化查询来更新表中的记录。
如下所示..
更新[tablename]设置Room_Code = [下拉值] St_Code = session [stcode]
Write a parameterized query on your dropdown's OnSelectedIndexChanged event to update the record in the table.
something like below..
Update [tablename] set Room_Code = [dropdown value] where St_Code = session["stcode"]
这篇关于使用下拉列表的值更新单个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!