Bonjour,
j'essaye de faire une edition de donnée comme le prevois le framework, mais ca ne marche pas pourquoi ?!?
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="myDataGrid" runat="server" BackColor="#FFE0C0" AutoGenerateColumns="False"
OnEditCommand="editionC"
OnCancelCommand="effacerC"
OnUpdateCommand="MAJC">
<Columns>
<asp:BoundColumn DataField="id" HeaderText="Id" FooterText="Id" SortExpression="id" />
<asp:BoundColumn DataField="montant" HeaderText="Montant" FooterText="montant" SortExpression="montant" />
<asp:EditCommandColumn ButtonType='LinkButton' CancelText='effacer' EditText='edition' UpdateText='mise a jour' HeaderText='quoifaire' />
</Columns>
</asp:DataGrid>
<asp:Label ID="myLabel" Runat="server" />
</form>
//CODE BEHIND
public class WebForm1 : System.Web.UI.Page
{
protected Label myLabel;
protected System.Web.UI.WebControls.DataGrid myDataGrid;
private void Page_Load(object sender, System.EventArgs e){
dataGridBinding();
}
private void dataGridBinding(){
SqlConnection oSqlConnection = new SqlConnection("data source=*****");
oSqlConnection.Open();
SqlDataAdapter oSqlDataAdapter = new SqlDataAdapter("SELECT * FROM table ",oSqlConnection);
DataSet oDataSet = new DataSet("operation");
oSqlDataAdapter.Fill(oDataSet,"operation");
myDataGrid.DataSource = oDataSet;
myDataGrid.DataBind();
}
protected void MAJC(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e){
myLabel.Text = "1";
}
protected void effacerC(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e){
myLabel.Text = "2";
}
protected void editionC(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e){
myLabel.Text = "3";
}
merci a vous