Bonjour, j'ai une gridview et j'ai un bouton pour chaque ligne, je veux quand je clique sur le bouton dans chaque ligne obtenir la valeur de 'lindex+ autre traitement
pour cela j'ai fait :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <asp:Button ID="AddButton" runat="server" CommandName="AddToCart" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
                                                    Text="Add to Cart" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
et dans le code c# :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
    protected void listeStations_RowCommand(object sender,GridViewCommandEventArgs e)
    {
        if (e.CommandName == "AddToCart")
        {
            // Retrieve the row index stored in the 
            // CommandArgument property.
            int index = Convert.ToInt32(e.CommandArgument);
            txtinvisible.Text = index.ToString();
            // Retrieve the row that contains the button 
            // from the Rows collection.
            GridViewRow row = listeStations.Rows[index];
 
            // Add code here to add the item to the shopping cart.
        }
 
    }
mais rien ne se passe mais l'arret ne se prend pas en charge, pourriez vous m'aider ?