运行结果:
初始状态:
现在问题是如何把运行结果中任意点击一行或一列,把这一行的信息回填到数据库表中。
初始状态:
现在问题是如何把运行结果中任意点击一行或一列,把这一行的信息回填到数据库表中。
解决方案 »
- 求高手指点
- 怎么查询gridview中的数据
- 怎样让ObjectDataSource重新加载数据
- datagrid分頁問題??求教
- dataset.select()返回的对象能不能做为绑定datagrid的datasource?
- !!!!关于表格宽度的小问题??
- 高分求:Dotnet下这种效果怎么实现?
- 高分求救!!!使用NetAdvantage 2005 Volume 1中的chart图表控件总是不成功!!
- 点击treeview,获得所选节点的id以及传递参数问题,在线等(第一次发贴,请多照顾,感激不尽)
- 简单代码,书上原码,有些不懂,请问各们高手!(2)
- 一个js问提,高手快来啊!
- 帮忙写个sql语句
是不是在DataGridView添加数据如后把这添加的数据保存到数据库中?
http://blog.csdn.net/JiaoPengJay/archive/2010/02/03/5285252.aspx
这个是我写的在DataGridView中实现增删改查
也有获取当前选中的单元格的值
可能对你有所帮助
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OracleClient;
using System.Data.SqlClient;
namespace WindowsApplication2
{
public partial class Form2 : Form
{
private DataView dv = null;
string sql = "";
string Enabled = "";
private string strconnection = "";
private OracleConnection myconnection = null;
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
strconnection = "Data Source=orcl9i ;Persist Security Info=True;User ID=scmis;Password=lgmis;";
myconnection = new OracleConnection(strconnection);
Init();
}
private void Init()
{
string sql = "select taskno as 任务单编号,taskcontext as 任务单内容描述,receiver as 接收人,planendtime as 计划完成时间,receiverno as 接受人工号,receivetime as 接收时间,senderno as 下达人工号 ,sender as 下达人,sendtime as 下达时间,task_status as 任务单状态 from T_INTERFACE_TICKETINFO";
sql += " where to_date(sendtime ,'yyyy-MM-dd HH24:MI:SS') between to_date('" + start.Value + "','yyyy-MM-dd HH24:MI:SS') and to_date('" + end.Value + "','yyyy-MM-dd HH24:MI:SS')";
DataSet ds = ExecuteDatasetFromSql(sql);
dataGridView1.DataSource = ds.Tables[0];
//dataGridView1.da();
}
public DataSet ExecuteDatasetFromSql(string sqlcmd)
{
DataSet ds = new DataSet();
try
{
myconnection.Open();
OracleDataAdapter da = new OracleDataAdapter(sqlcmd, myconnection);
OracleCommandBuilder orbc = new OracleCommandBuilder(da);
da.Fill(ds);
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
finally
{
myconnection.Close();
}
return ds;
}
private void Search_Click(object sender, EventArgs e)
{
Init();
}
private void Ok_Click(object sender, EventArgs e)
{
[size=24px] 问题就是这里,请把代码补充完整!!这就是问题的所在!! [/size
}
}
{
问题就是这里,请把代码补充完整!!这就是问题的所在!!
} 请高手指点下!!!
如果是这样的话:
在click事件中代码如下
if (datagridview1.CurrentCell.RowIndex >= 0)//确定选择不是列头
{
string aa = datagridview1.CurrentRow.Cells[0].Value.ToString();//获取该行第一个列的值
string bb = datagridview1.CurrentRow.Cells[1].Value.ToString();//获取该行第二个列的值
……依次类推;假如第三列的值是double型的,那么这样可以写:
double cc = double.parse(datagridview1.CurrentRow.Cells[0].Value.ToString());//获取该行第三个列的值
获取完值以后,你就以这些值为条件往数据库里添加就可以了!至于连接数据库阿,sql语句阿什么的旧不用我说了吧。不懂的发消息,噢
}