Bonjour à tous,

J'ai un bug bizzare.

J'ai un gridView avec 2 ButtonFields :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
<asp:GridView AutoGenerateColumns="false" ID="gvLigands" runat="server" GridLines="Horizontal"
        CellPadding="5" RowStyle-HorizontalAlign="Center" OnSelectedIndexChanged ="gvLigands_SelectedIndexChanged" OnRowCommand = "gvLigands_RowCommand">
        <Columns>
            <asp:buttonfield ButtonType="Image" CommandName="Remove" ImageUrl="~/Images/Delete_new.png" />
            <asp:buttonfield ButtonType="Image" CommandName="Edit" ImageUrl="~/Images/Edit_new2.png" />
            <asp:BoundField DataField="BoxName" HeaderText="Box Name" />
            <asp:BoundField DataField="DateReceived" HeaderText="Date Received" />
            <asp:BoundField DataField="AmountReceived" HeaderText="Amount received" />
            <asp:BoundField DataField="Comments" HeaderText="Comments" />
        </Columns>
    </asp:GridView>
Et le code behind suivant :

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
17
18
19
 
protected void gvLigands_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string commandName = Convert.ToString(e.CommandName);
            int rowNumber = Convert.ToInt32(e.CommandArgument);
 
string dummy = "";
 
//Le code va toujours sur "pas IsPostback"
if (!IsPostback)
{
dummy = "pas IsPostback";
}
else
{
dummy = "IsPostback";
}
 
     }
Quand je clique sur un ButtonField IsPostback est toujours false.

Cela me pose un problème car j'aurai des tests à faire sur !IsPostback.

Merci beaucoup par avance.

Laurent.