Bonjour, j'ai un tableau contenant une liste d'id identifiant des pieces relatif a a un dossier, et un grid view contenant la liste des pieces qui existe, je veux parcourir le tableau et recuperer id et cocher les lignes sur gridview.

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
int aa = 0;
        for (int g = 0; g < gridpieces.Rows.Count;g++ )
        {
            for (int i = aa; i < len; i++)
            {
                if (tabPieces[i] == Convert.ToInt16(gridpieces.Rows[g].Cells[3]))
                {
                    CheckBox ch = (CheckBox)(gridpieces.Rows[g].Cells[0]);
                    ch.Checked=true;
                    aa = aa + 1;
                    break;
                }
            }
 
        }
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
20
21
22
23
24
25
26
27
<asp:GridView ID="gridpieces" runat="server" AutoGenerateColumns="False" 
                                        BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" 
                                        CellPadding="4" DataSourceID="SDS_pieces" ForeColor="Black" 
                                        GridLines="Horizontal" ShowHeader="false">
                                        <Columns>
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="CheckBox1" runat="server" />
                                                </ItemTemplate>
                                            </asp:TemplateField>
 
                                            <asp:BoundField DataField="Intitulé" HeaderText="Intitulé" 
                                                SortExpression="Intitulé" />
                                            <asp:CheckBoxField DataField="Facultatif" HeaderText="Facultatif" 
                                                SortExpression="Facultatif" Visible="False" />
                                                <asp:CheckBoxField DataField="ID_Piece" HeaderText="" 
                                                SortExpression="ID_Piece" Visible="False" />
                                        </Columns>
                                        <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
                                        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
                                        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
                                        <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
                                        <SortedAscendingCellStyle BackColor="#F7F7F7" />
                                        <SortedAscendingHeaderStyle BackColor="#4B4B4B" />
                                        <SortedDescendingCellStyle BackColor="#E5E5E5" />
                                        <SortedDescendingHeaderStyle BackColor="#242121" />
                                    </asp:GridView>

Merci