bonjour les professionnels.. j'ai besoin de vos aides
j'ai un gridview ou j'ai deux colonne ou la première colonne est une asp:BoundField que j'alimente a partir d'une table ["GARENTIE"] et la deuxième et un ensemble de asp: DropDownList ke j'alimente chacune d'une autre table ["TYPE_GAREBTIE"], mais je veux enregistrer après le click sur le button enregistrer tout le gridview dans une troisième table ["RELATION_PRODUIT_GARENTIE_TYPE"]
apres le choix de la section la liste des garentie qu'on a dans cette section s'affiche
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 <asp:GridView ID="Garentie" OnRowDataBound="Garentie_RowDataBound" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None"> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <Columns> <asp:BoundField HeaderText="Garenties" DataField="libelleGarentie" /> <asp:TemplateField HeaderText="Type de la garentie"> <ItemTemplate> <asp:DropDownList ID="ddlTypeGarentie" runat="server"> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> </Columns> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 protected void ddlsection_SelectedIndexChanged(object sender, EventArgs e) { int id = Convert.ToInt32(ddlsection.SelectedItem.Value); LoadGarentieBySection(id); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 private void LoadGarentieBySection(int id) { List<Garentie> garentie = _dalGarentie.GetListGarentieBySection(id); Garentie.DataSource = garentie; Garentie.DataBind(); }
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
28
29
30
31
32
33
34
35 public List<Garentie> GetListGarentieBySection(int id) { List<Garentie> listeGarentie = new List<Garentie>(); Garentie g = null; Database _db = DatabaseFactory.CreateDatabase(); string req = " SELECT GARENTIE.* " + " FROM SECTION " + " INNER JOIN R_GARENT_SECT ON SECTION.ID_SECTION = R_GARENT_SECT.ID_SECTION " + " INNER JOIN GARENTIE ON R_GARENT_SECT.ID_GARENTIE = GARENTIE.ID_GARENTIE " + " WHERE SECTION.ID_SECTION = :Id " ; DbCommand selectCommand = _db.GetSqlStringCommand(req); selectCommand.CommandType = CommandType.Text; _db.AddInParameter(selectCommand, "Id", DbType.Int32, id); using (IDataReader dataReader = _db.ExecuteReader(selectCommand)) { // Processing code while (dataReader.Read()) { g = new Garentie(); g.LibelleGarentie = Utilities.DbObjectToString(dataReader["LIBELLE_GARENTIE"]); g.IdGarentie = Utilities.DbObjectToInt(dataReader["ID_GARENTIE"]); listeGarentie.Add(g); } } return listeGarentie; }
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 protected void Garentie_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DropDownList ddlTypeGarentie = (DropDownList)e.Row.FindControl("ddlTypeGarentie"); ddlTypeGarentie.DataSource = _dalGarentie.LoadRefObjectStatusByName("TYPE_GARENTIE"); ddlTypeGarentie.DataValueField = "ID_TYPE_GARENTIE"; ddlTypeGarentie.DataTextField = "LIBELLE_TYPE_GARENTIE"; ddlTypeGarentie.DataBind(); ddlTypeGarentie.Items.Insert(0, new ListItem("--Choisir un type de garentie--", "")); } }
P.S: je travail avec le SGBD ORACLE 10g
Partager