bonjour, voila
//------------------------------ ne copie pas cette ligne coté C# ----------------------------------------------------------------------------------------------------
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable table = new DataTable();
DataRow row = null;
// aprés la bocle for afectation de la table au gridview
GridView1.DataSource = table;
GridView1.DataBind();
}
}
//------------------------------- un petit astuce pour accéder aux objet du gridview
protected void Button1_Click(object sender, EventArgs e)
{
int i = Convert.ToInt16(((Button)(sender)).CommandArgument); // pour quoi CommandArgument
// parce que jai mis dans le grid CommandArgument a Eval("Ligne") qui reçoit i (voir code aspx)
// Eval("Ligne") veux dire remplire CommandArgument du button avec la clé primaire Ligne
// maintenant accé aux objet
((Label)GridView1.Rows[i].FindControl("Label1")).Text = "Ligne " +i.ToString();
//--------------------------- ne copie pas cette ligne coté aspx -------------------------------------------------------------------------------------------------------