我的查询是
SELECT
deldate,
transno,
matno,
MAT_NAME,
rawpkgno,
MAX(SWITCH(deldate=? ,ORDCASES )) AS [CURRDATE],
MAX(SWITCH(deldate=? ,ORDCASES )) AS [previous_day],
MAX(SWITCH(deldate=? ,ORDCASES )) AS [Last_date]
FROM
invorder
WHERE
invorder.strno =54009
OR [invorder.deldate] IS NULL
GROUP BY
matno,
MAT_NAME,
rawpkgno,
transno,
deldate
我想从gridview编辑它。由于这是视图,我无法从gridview编辑它。但是他们可以通过previous_day
,Last_date
列保持不变,而且我只能对CURRDATE
列进行更改。请帮助我。
答案 0 :(得分:0)
嗨,你必须在网格上绑定row_added事件,并且除了你想要编辑之外,所有单元格都是只读的。检查下面的代码..
public Form1()
{
InitializeComponent();
dataGridView1.RowsAdded += new DataGridViewRowsAddedEventHandler(dataGridView1_RowsAdded);
}
void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
foreach (DataGridViewCell item in dataGridView1.Rows[e.RowIndex].Cells)
{
// here i used the 5 because i want to make the 5th index cell as editable.
if (item.ColumnIndex == 5)
{
continue;
}
item.ReadOnly = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = bind_your_data_source_here;
dataGridView1.Refresh();
}
你可以从这里找到样品.. Download