1
나는 ASP.net 프로젝트로 작업하고 있고 datasource로 SQL 데이터베이스에서 데이터 집합이있는 gridview 있습니다.gridview 가져 오기 열 머리글 편집 후
gridview에서 값을 변경할 때 해당 데이터 집합을 사용하여 데이터베이스를 다시 업데이트 할 수 있도록 데이터 집합을 업데이트하고 싶습니다.
나는 지금까지 가지고있는 진술.
문제가있는 부분입니다. 선택한 행을 가져올 수 있지만 선택한 열 이름을 사용하여 데이터 집합을 업데이트 할 수 없습니다.
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);
}