-1

グリッドテーブルには、データベースによって埋められた5つの行があります。
どこかを削除したい場合。

解決:

datatableTempを作成し、gridViewで削除した後、テーブルTempも削除します。
その後、tableTempでGridViewを埋めます。

//========Get datatable from database.
dtTempGrdBlockForDeviceByRole = Cls_BLOCKS.getDataTable_WriteField();
grdBlockForDeviceByRole = Cls_BLOCKS.getDataTable_WriteField();            
for (int x = 0; x < grdBlockForDeviceByRole.Rows.Count; x++)
{
    CheckBox chk = grdBlockForDeviceByRole.Rows[x].FindControl("ckDelete") as CheckBox;
    string txtD = grdBlockForDeviceByRole.Rows[x].Cells[0].Text;                
    if (chk.Checked)
    {
        //If choice   
        //What should we do in here?         
    }                
}
grdBlockForDeviceByRole.DataSource = dtTempGrdBlockForDeviceByRole;
grdBlockForDeviceByRole.DataBind();

あなたは私を助けることができます?

4

1 に答える 1

1

次のようにコードを使用できます。

dtTempGrdBlockForDeviceByRole = Cls_BLOCKS.getDataTable_WriteField();
grdBlockForDeviceByRole = Cls_BLOCKS.getDataTable_WriteField();            
for (int x = 0; x < grdBlockForDeviceByRole.Rows.Count; x++)
{
    CheckBox chk = grdBlockForDeviceByRole.Rows[x].FindControl("ckDelete") as CheckBox;
    string txtD = grdBlockForDeviceByRole.Rows[x].Cells[0].Text;                
    if (chk.Checked)
    {
        dtTempGrdBlockForDeviceByRole.Rows.RemoveAt(x);  
    }                
}
grdBlockForDeviceByRole.DataSource = dtTempGrdBlockForDeviceByRole;
grdBlockForDeviceByRole.DataBind();

ありがとう

于 2013-02-25T09:04:08.620 に答える