使用项目模板在网格视图中使用dropdownlist将数据插入sql server? [英] insert data into sql server using dropdownlist in grid view, using item template?

查看:44
本文介绍了使用项目模板在网格视图中使用dropdownlist将数据插入sql server?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好...
我正在使用asp.net.我在我的网格视图中有三列. Rollno,Stu_name和出勤.我将其与sql server绑定.因此ist和第二栏中的数据将直接来自数据库.但在第三栏中,我正在使用下拉列表
(项目是-P,L,A),使用项目模板.所以现在当我要从三个选项中选择一个时,我希望数据将保存在数据库的第三列中.
请不要将gridview直接连接到数据库....通过将整个代码写入cs文件来连接它...请尽快告诉我.

hellooo...
i am using asp.net. ihad three column in my gridview. Rollno, Stu_name and Attendence. I bind it with sql server. so data in ist and second column will come directly from database. but in third column , i am using dropdown list
(items are- P, L, A) , using item template. so now when i will select any option out of three, i want that data will be save in database in third column.
plz dont connect gridview directly to database.... connect it by writing whole code into cs file... plz..tell me soon.

推荐答案

您好
您可以使用
找到控件
Hi
You can find the control using
If (Not gv.Rows(e.RowIndex).FindControl("ddlOpArea") Is Nothing) Then
              oparea = CType(gv.Rows(e.RowIndex).FindControl("ddlOpArea"), DropDownList).SelectedItem.Text.Trim




然后将值传递到DB.




Then pass the value into DB.


这篇关于使用项目模板在网格视图中使用dropdownlist将数据插入sql server?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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