시도 뭔가 :
가
Checked='<%# Eval("pric_c_alfsupreq").ToString().Equals("Y") %>'>
가 UPDATE : 당신이 오래된 데이터 그리드을 사용하고 있기 때문에
(당신이 요즘 DataGridView를를 사용한다), 비슷한 무언가를해야한다 DataGrid
정의 :
<asp:DataGrid ID="Grid" runat="server" PageSize="5" AllowPaging="True"
DataKeyField="EmpId" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="No"
OnPageIndexChanged="Grid_PageIndexChanged"
OnCancelCommand="Grid_CancelCommand"
OnDeleteCommand="Grid_DeleteCommand"
OnEditCommand="Grid_EditCommand"
OnUpdateCommand="Grid_UpdateCommand">
protected void Grid_UpdateCommand(object source, DataGridCommandEventArgs e)
{
con = new SqlConnection(ConfigurationManager.AppSettings["connect"]);
char value = "N"
// You'll have to change the index here to point to the CheckBox you have in
// your DataGrid.
// It can be on index 1 Controls[1] or 2 Controls[2]. Only you know this info.
if(((CheckBox)e.Item.Cells[0].Controls[0]).Checked == true)
{
value = "Y";;
}
cmd.Parameters.Add("@pric_c_alfsupreq", SqlDbType.Char).Value = value;
cmd.CommandText = "Update command HERE";
cmd.Connection = con;
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
Grid.EditItemIndex = -1;
}
당신이 아이디어를 얻을 희망 :
은 행의 데이터에 업데이트를 적용 할 때 실행해야 OnUpdateCommand ...
이제 방법을 참조하십시오. 다른 순간에이 코드가 필요하면 OnEditCommand
, OnDeleteCommand
등의 코드에 넣을 수 있습니다.
로 전화를? DataGrid 또는 DataGridView? –
DataGrid 나는 –