私はASP.netプロジェクトで作業しており、SQLデータベースのデータセットをデータソースとして持つグリッドビューを持っています。
グリッドビューの値を変更したら、データセットを更新して、そのデータセットを使用してデータベースを再度更新できるようにします。
私がこれまでに持っている声明。
これは私が問題を抱えている部分です。選択した行を取得できますが、データセットを更新するために選択した列名は取得できません。
myDataSet.Tables[0].Rows[e.RowIndex][?] = "";
RowUpdating イベントの完全なコード。
protected void grdViewDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//Just get the dataset populated from my database (sql)
DataSet dsOriginal = dbConn.returnSqlDataset(query);
//update the dataset here so that you can update the database again.
foreach (TableCell cell in grdViewDetails.Rows[e.RowIndex].Cells)
{
//set the employeeid so you can update the dataset
if (cell.Controls[0] is TextBox)
{
TextBox textbox = (TextBox)cell.Controls[0];
string value = textbox.Text; //This is just a tester to see if the value is correct
// dsOriginal.Tables[0].Rows[e.RowIndex][?] = value; //Here is the problem, how to get the selected column name
}
else
{
if (cell.Controls[0] is CheckBox)
{
CheckBox chkBoxWeek = (CheckBox)cell.Controls[0];
Boolean checkStatus = chkBoxWeek.Checked; //This is just a tester to see if the value is correct
//dsOriginal.Tables[0].Rows[e.RowIndex][?] = checkStatus; //Here is the problem, how to get the selected column name
}
}
}
//Use the updated dataset to update the database with.
dbConn.udpatCourse(dsOriginal );
}