我想在formview中使用dropdownlist但不能在数据库中插入dropdownlist选择的值, [英] i want to use dropdownlist in formview but not able to insert dropdownlist selected value in database,

查看:94
本文介绍了我想在formview中使用dropdownlist但不能在数据库中插入dropdownlist选择的值,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在asp.net Web应用程序的表单视图中使用DropdownList将数据从列表插入数据库。我尝试使用< asp:DropDownList />

请任何机构都可以给我代码,使用formview或手动将数据从dropddownlist插入数据库





谢谢

I want to use DropdownList in form view in asp.net web application to insert data from list to database. I tried using <asp:DropDownList />
Please any body can give me code for this to insert data from dropddownlist to database using formview or by manual


Thanks

推荐答案

这并不困难digvijay。我相信你正在使用formview中的insert模板来执行insert.if not,让我知道。



关于表单插入事件的表单视图添加下面的代码:



var ddl = FormView1.FindControl(ddlcourse);


如果ddl.selectedindex>
; -1然后

yoursqldatasource.insertparameters(course)。defaultvalue = ddl.selectedvalue

end if;





所以你的sqldatasource应该有一个insertcommand和insert参数。



我希望这会有所帮助。
This is not difficult digvijay. I believe you are using the insert template in formview to do the insert.if not, let me know.

on the item inserting event for form view add the below code:

var ddl = FormView1.FindControl("ddlcourse");

if ddl.selectedindex > -1 then
yoursqldatasource.insertparameters("course").defaultvalue = ddl.selectedvalue
end if;


so your sqldatasource should have an insertcommand and insert parameters.

I hope this helps.


这并不困难digvijay。我相信你正在使用formview中的insert模板来执行insert.if not,让我知道。



关于表单插入事件的表单视图添加下面的代码:



var ddl = FormView1.FindControl(ddlcourse);

如果ddl.selectedindex> -1然后

yoursqldatasource.insertparameters(course)。defaultvalue = ddl.selectedvalue

end if;

yoursqldatasource.insert();





所以你的sqldatasource应该有一个insertcommand和insert参数。



我希望这会有所帮助。
This is not difficult digvijay. I believe you are using the insert template in formview to do the insert.if not, let me know.

on the item inserting event for form view add the below code:

var ddl = FormView1.FindControl("ddlcourse");
if ddl.selectedindex > -1 then
yoursqldatasource.insertparameters("course").defaultvalue = ddl.selectedvalue
end if;
yoursqldatasource.insert();


so your sqldatasource should have an insertcommand and insert parameters.

I hope this helps.


以下内容应指导您如何实施: MSDN:使用FormView Web服务器控件修改数据 [ ^ ]



附加提示:有一个下拉列表在项目/编辑模板中根据需要,然后访问它以获得选定的值。用于更新。



试试看。如果您面临发布特定问题。
Following should guide you on how to approach the implementation: MSDN: Modifying Data Using a FormView Web Server Control[^]

Additional hint: Have a dropdown in item/edit template as per need and then access that to get selected value. Use that for updation.

Try out. Post specific issue if you face.


这篇关于我想在formview中使用dropdownlist但不能在数据库中插入dropdownlist选择的值,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆