Erreur lors de suppression de ligne dans un tableau
Bonjour à tous,
Je viens vers vous suite à un problème assez énervant dont voici le message d'erreur :
Citation:
L'argument spécifié n'était pas dans les limites de la plage des valeurs valides.
Nom du paramètre : value
J'ai 2 tableaux. Le but est que, lors d'une suppression de ligne dans le 1er tableau, cela en ajoute une dans le second (et inversement).
Les requêtes SQL fonctionnent bien.
J'ai une colonne "Coût total" qui représente la multiplication de 2 colonnes (opération effectuée dans la requête SQL).
Dès que le coût est supérieur à la valeur 1000 (par exemple), cela produit une erreur quand j'essaie de supprimer la ligne en question.
Voici mon code :
Code:
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
| <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ActivityValidationST.ascx.cs" Inherits="ActivityValidationST" %>
<style>
.cellHeaderRight
{
vertical-align:bottom;
}
.cellTableRowHeader
{
text-align: left;
vertical-align:bottom;
background-color: #507CD1;
font-weight: bold;
color: White;
}
.cellTableColHeader
{
text-align: right;
vertical-align:bottom;
background-color: #507CD1;
font-weight: bold;
color: White;
}
.cellTotalLeft
{
}
</style>
<!-- Variables pour suivre l état du composant -->
<asp:Label ID="lblUserLogn" runat="server" Text="" Visible="false"></asp:Label>
<asp:Label ID="lblUserPrflNumb" runat="server" Visible="false" ></asp:Label>
<asp:Label ID="lblTime" runat="server" Text="" Visible="false"></asp:Label>
<!-- Sélection du mois -->
Mois :
<asp:DropDownList ID="ddlTime" runat="server" AutoPostBack="True" DataSourceID="TimeSqlDataSource"
DataTextField="mnth_lib" DataValueField="mnth_id">
</asp:DropDownList>
<asp:SqlDataSource ID="TimeSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:csIntranet %>"
SelectCommand="GetMonthsPast" SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
<asp:Label ID="lblError" runat="server" Text="Vous ne pouvez pas afficher ce choix" ForeColor="red" Visible="false"></asp:Label><br />
<!-- GridView principal -->
<asp:GridView ShowHeader="false" DataKeyNames="mnth_id, srvc_id" ID="gvActivityValidation"
OnRowDataBound="gvActivityValidation_RowDataBound" Font-Names="Arial" Font-Size="10pt" runat="server"
AutoGenerateColumns="False" DataSourceID="ActivityValidationSqlDataSource" OnRowDeleted="gvActivityValidation_RowDeleted">
<Columns>
<asp:BoundField DataField="mnth_id" HeaderText="mnth_id" ReadOnly="True" SortExpression="mnth_id" Visible="false" />
<asp:BoundField DataField="srvc_id" HeaderText="srvc_id" ReadOnly="True" SortExpression="srvc_id" Visible="false" />
<asp:BoundField DataField="srvc_desc" HeaderText="srvc_desc" ReadOnly="True" SortExpression="srvc_desc" />
<asp:BoundField DataField="qty_01" HeaderText="qty_01" ReadOnly="True" SortExpression="qty_01" />
<asp:BoundField DataField="qty_02" HeaderText="qty_02" ReadOnly="True" SortExpression="qty_02" />
<asp:BoundField DataField="qty_03" HeaderText="qty_03" ReadOnly="True" SortExpression="qty_03" />
<asp:BoundField DataField="qty_04" HeaderText="qty_04" ReadOnly="True" SortExpression="qty_04" />
<asp:BoundField DataField="qty_05" HeaderText="qty_05" ReadOnly="True" SortExpression="qty_05" />
<asp:BoundField DataField="qty_06" HeaderText="qty_06" ReadOnly="True" SortExpression="qty_06" />
<asp:BoundField DataField="qty_07" HeaderText="qty_07" ReadOnly="True" SortExpression="qty_07" />
<asp:BoundField DataField="qty_08" HeaderText="qty_08" ReadOnly="True" SortExpression="qty_08" />
<asp:BoundField DataField="qty_09" HeaderText="qty_09" ReadOnly="True" SortExpression="qty_09" />
<asp:BoundField DataField="qty_10" HeaderText="qty_10" ReadOnly="True" SortExpression="qty_10" />
<asp:BoundField DataField="qty_11" HeaderText="qty_11" ReadOnly="True" SortExpression="qty_11" />
<asp:BoundField DataField="qty_12" HeaderText="qty_12" ReadOnly="True" SortExpression="qty_12" />
<asp:BoundField DataField="qty_13" HeaderText="qty_13" ReadOnly="True" SortExpression="qty_13" />
<asp:BoundField DataField="qty_14" HeaderText="qty_14" ReadOnly="True" SortExpression="qty_14" />
<asp:BoundField DataField="qty_15" HeaderText="qty_15" ReadOnly="True" SortExpression="qty_15" />
<asp:BoundField DataField="qty_16" HeaderText="qty_16" ReadOnly="True" SortExpression="qty_16" />
<asp:BoundField DataField="qty_17" HeaderText="qty_17" ReadOnly="True" SortExpression="qty_17" />
<asp:BoundField DataField="qty_18" HeaderText="qty_18" ReadOnly="True" SortExpression="qty_18" />
<asp:BoundField DataField="qty_19" HeaderText="qty_19" ReadOnly="True" SortExpression="qty_19" />
<asp:BoundField DataField="qty_20" HeaderText="qty_20" ReadOnly="True" SortExpression="qty_20" />
<asp:BoundField DataField="qty_21" HeaderText="qty_21" ReadOnly="True" SortExpression="qty_21" />
<asp:BoundField DataField="qty_22" HeaderText="qty_22" ReadOnly="True" SortExpression="qty_22" />
<asp:BoundField DataField="qty_23" HeaderText="qty_23" ReadOnly="True" SortExpression="qty_23" />
<asp:BoundField DataField="qty_24" HeaderText="qty_24" ReadOnly="True" SortExpression="qty_24" />
<asp:BoundField DataField="qty_25" HeaderText="qty_25" ReadOnly="True" SortExpression="qty_25" />
<asp:BoundField DataField="qty_26" HeaderText="qty_26" ReadOnly="True" SortExpression="qty_26" />
<asp:BoundField DataField="qty_27" HeaderText="qty_27" ReadOnly="True" SortExpression="qty_27" />
<asp:BoundField DataField="qty_28" HeaderText="qty_28" ReadOnly="True" SortExpression="qty_28" />
<asp:BoundField DataField="qty_29" HeaderText="qty_29" ReadOnly="True" SortExpression="qty_29" />
<asp:BoundField DataField="qty_30" HeaderText="qty_30" ReadOnly="True" SortExpression="qty_30" />
<asp:BoundField DataField="qty_31" HeaderText="qty_31" ReadOnly="True" SortExpression="qty_31" />
<asp:BoundField DataField="cost_rate" HeaderText="cost_rate" ReadOnly="True" SortExpression="cost_rate" />
<asp:BoundField DataField="qty_tot" HeaderText="qty_tot" ReadOnly="True" SortExpression="qty_tot" />
<asp:BoundField DataField="total_cost" HeaderText="total_cost" ReadOnly="True" SortExpression="total_cost" />
<asp:CommandField ShowDeleteButton="True" DeleteText="Valider" >
<HeaderStyle CssClass="cellHeaderRight" />
<ItemStyle CssClass="cellTotalLeft" />
</asp:CommandField>
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="ActivityValidationSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:csIntranet %>"
DeleteCommand="ActivityValidationSTValidate" DeleteCommandType="StoredProcedure"
SelectCommand="ActivityValidationSTSelect" SelectCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="mnth_id" Type="Int32" />
<asp:Parameter Name="srvc_id" Type="Int32" />
<asp:ControlParameter ControlID="lblUserLogn" Name="user_logn" PropertyName="Text" Type="String" />
</DeleteParameters>
<SelectParameters>
<asp:ControlParameter ControlID="lblUserLogn" Name="user_logn" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="lblUserPrflNumb" Name="user_prfl_numb" PropertyName="Text" Type="Int32" />
<asp:ControlParameter ControlID="ddlTime" Name="mnth_id" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<br /><br />
Activité validée et non encore facturée, pour dévalidation si nécessaire: <br />
<!-- GridView pour la dévalidation -->
<asp:GridView ShowHeader="false" DataKeyNames="mnth_id, srvc_id" ID="gvActivityDevalidation"
OnRowDataBound="gvActivityDevalidation_RowDataBound" Font-Names="Arial" Font-Size="10pt" runat="server"
AutoGenerateColumns="False" DataSourceID="ActivityDevalidationSqlDataSource" OnRowDeleted="gvActivityDevalidation_RowDeleted">
<Columns>
<asp:BoundField DataField="mnth_id" HeaderText="mnth_id" ReadOnly="True" SortExpression="mnth_id" Visible="false" />
<asp:BoundField DataField="srvc_id" HeaderText="srvc_id" ReadOnly="True" SortExpression="srvc_id" Visible="false" />
<asp:BoundField DataField="srvc_desc" HeaderText="srvc_desc" ReadOnly="True" SortExpression="srvc_desc" />
<asp:BoundField DataField="qty_01" HeaderText="qty_01" ReadOnly="True" SortExpression="qty_01" />
<asp:BoundField DataField="qty_02" HeaderText="qty_02" ReadOnly="True" SortExpression="qty_02" />
<asp:BoundField DataField="qty_03" HeaderText="qty_03" ReadOnly="True" SortExpression="qty_03" />
<asp:BoundField DataField="qty_04" HeaderText="qty_04" ReadOnly="True" SortExpression="qty_04" />
<asp:BoundField DataField="qty_05" HeaderText="qty_05" ReadOnly="True" SortExpression="qty_05" />
<asp:BoundField DataField="qty_06" HeaderText="qty_06" ReadOnly="True" SortExpression="qty_06" />
<asp:BoundField DataField="qty_07" HeaderText="qty_07" ReadOnly="True" SortExpression="qty_07" />
<asp:BoundField DataField="qty_08" HeaderText="qty_08" ReadOnly="True" SortExpression="qty_08" />
<asp:BoundField DataField="qty_09" HeaderText="qty_09" ReadOnly="True" SortExpression="qty_09" />
<asp:BoundField DataField="qty_10" HeaderText="qty_10" ReadOnly="True" SortExpression="qty_10" />
<asp:BoundField DataField="qty_11" HeaderText="qty_11" ReadOnly="True" SortExpression="qty_11" />
<asp:BoundField DataField="qty_12" HeaderText="qty_12" ReadOnly="True" SortExpression="qty_12" />
<asp:BoundField DataField="qty_13" HeaderText="qty_13" ReadOnly="True" SortExpression="qty_13" />
<asp:BoundField DataField="qty_14" HeaderText="qty_14" ReadOnly="True" SortExpression="qty_14" />
<asp:BoundField DataField="qty_15" HeaderText="qty_15" ReadOnly="True" SortExpression="qty_15" />
<asp:BoundField DataField="qty_16" HeaderText="qty_16" ReadOnly="True" SortExpression="qty_16" />
<asp:BoundField DataField="qty_17" HeaderText="qty_17" ReadOnly="True" SortExpression="qty_17" />
<asp:BoundField DataField="qty_18" HeaderText="qty_18" ReadOnly="True" SortExpression="qty_18" />
<asp:BoundField DataField="qty_19" HeaderText="qty_19" ReadOnly="True" SortExpression="qty_19" />
<asp:BoundField DataField="qty_20" HeaderText="qty_20" ReadOnly="True" SortExpression="qty_20" />
<asp:BoundField DataField="qty_21" HeaderText="qty_21" ReadOnly="True" SortExpression="qty_21" />
<asp:BoundField DataField="qty_22" HeaderText="qty_22" ReadOnly="True" SortExpression="qty_22" />
<asp:BoundField DataField="qty_23" HeaderText="qty_23" ReadOnly="True" SortExpression="qty_23" />
<asp:BoundField DataField="qty_24" HeaderText="qty_24" ReadOnly="True" SortExpression="qty_24" />
<asp:BoundField DataField="qty_25" HeaderText="qty_25" ReadOnly="True" SortExpression="qty_25" />
<asp:BoundField DataField="qty_26" HeaderText="qty_26" ReadOnly="True" SortExpression="qty_26" />
<asp:BoundField DataField="qty_27" HeaderText="qty_27" ReadOnly="True" SortExpression="qty_27" />
<asp:BoundField DataField="qty_28" HeaderText="qty_28" ReadOnly="True" SortExpression="qty_28" />
<asp:BoundField DataField="qty_29" HeaderText="qty_29" ReadOnly="True" SortExpression="qty_29" />
<asp:BoundField DataField="qty_30" HeaderText="qty_30" ReadOnly="True" SortExpression="qty_30" />
<asp:BoundField DataField="qty_31" HeaderText="qty_31" ReadOnly="True" SortExpression="qty_31" />
<asp:BoundField DataField="cost_rate" HeaderText="cost_rate" ReadOnly="True" SortExpression="cost_rate" />
<asp:BoundField DataField="qty_tot" HeaderText="qty_tot" ReadOnly="True" SortExpression="qty_tot" />
<asp:BoundField DataField="total_cost" HeaderText="total_cost" ReadOnly="True" SortExpression="total_cost" />
<asp:CommandField ShowDeleteButton="True" DeleteText="Dévalider" >
<HeaderStyle CssClass="cellHeaderRight" />
<ItemStyle CssClass="cellTotalLeft" />
</asp:CommandField>
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="ActivityDevalidationSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:csIntranet %>"
DeleteCommand="ActivityValidationSTDevalidate" DeleteCommandType="StoredProcedure"
SelectCommand="ActivityDevalidationSTSelect" SelectCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="mnth_id" Type="Int32" />
<asp:Parameter Name="srvc_id" Type="Int32" />
<asp:ControlParameter ControlID="lblUserLogn" Name="user_logn" PropertyName="Text" Type="String" />
</DeleteParameters>
<SelectParameters>
<asp:ControlParameter ControlID="ddlTime" Name="mnth_id" PropertyName="SelectedValue" Type="Int32" />
<asp:ControlParameter ControlID="lblUserLogn" Name="user_logn" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="lblUserPrflNumb" Name="user_prfl_numb" PropertyName="Text" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource> |
et le .cs :
Code:
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
public partial class ActivityValidationST : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
lblUserLogn.Text = System.Web.HttpContext.Current.User.Identity.Name.Split('\\').GetValue(1).ToString();
// Ajout le 20071110 pour la gestion de la sécurité par les groupes NT
int iUserPrflNumb = 0;
if (System.Web.HttpContext.Current.User.IsInRole("WSS Activité")) iUserPrflNumb += 2;
if (System.Web.HttpContext.Current.User.IsInRole("WSS Activité Admin")) iUserPrflNumb += 4;
if (System.Web.HttpContext.Current.User.IsInRole("WSS DAF")) iUserPrflNumb += 8;
if (System.Web.HttpContext.Current.User.IsInRole("WSS DAF Admin")) iUserPrflNumb += 16;
if (System.Web.HttpContext.Current.User.IsInRole("WSS DRH")) iUserPrflNumb += 32;
if (System.Web.HttpContext.Current.User.IsInRole("WSS DRH Admin")) iUserPrflNumb += 64;
if (System.Web.HttpContext.Current.User.IsInRole("WSS Client")) iUserPrflNumb += 128;
if (System.Web.HttpContext.Current.User.IsInRole("WSS Interne")) iUserPrflNumb += 256;
if (System.Web.HttpContext.Current.User.IsInRole("WSS Commercial")) iUserPrflNumb += 512;
if (System.Web.HttpContext.Current.User.IsInRole("WSS Commercial Admin")) iUserPrflNumb += 1024;
if (System.Web.HttpContext.Current.User.IsInRole("WSS Administrateur")) iUserPrflNumb += 2048;
lblUserPrflNumb.Text = iUserPrflNumb.ToString();
}
protected void gvActivityValidation_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Affichage de la liste déroulante pour le Non renseigné / Hors prestation
if (DataBinder.Eval(e.Row.DataItem, "qty_tot").Equals(DBNull.Value))
{
e.Row.Cells[2].CssClass = "cellTableRowHeader";
for (int iCol = 3; iCol <= 33; iCol++)
{
e.Row.Cells[iCol].CssClass = "cellTableColHeader";
if (e.Row.Cells[iCol].Text.IndexOf(",") > 0)
e.Row.Cells[iCol].Text = e.Row.Cells[iCol].Text.Substring(0, e.Row.Cells[iCol].Text.IndexOf(","));
}
e.Row.Cells[34].CssClass = "cellTableColHeader";
e.Row.Cells[34].Text = "Coût/jour";
e.Row.Cells[35].CssClass = "cellTableColHeader";
e.Row.Cells[35].Text = "Total";
e.Row.Cells[36].CssClass = "cellTableColHeader";
e.Row.Cells[36].Text = "Coût Total";
e.Row.Cells[37].CssClass = "cellTableColHeader";
e.Row.Cells[37].Text = "Action";
}
}
}
protected void gvActivityDevalidation_RowDeleted(object sender, EventArgs e)
{
gvActivityValidation.DataBind();
}
protected void gvActivityValidation_RowDeleted(object sender, EventArgs e)
{
gvActivityDevalidation.DataBind();
}
protected void gvActivityDevalidation_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Affichage de la liste déroulante pour le Non renseigné / Hors prestation
if (DataBinder.Eval(e.Row.DataItem, "qty_tot").Equals(DBNull.Value))
{
e.Row.Cells[2].CssClass = "cellTableRowHeader";
for (int iCol = 3; iCol <= 33; iCol++)
{
e.Row.Cells[iCol].CssClass = "cellTableColHeader";
if (e.Row.Cells[iCol].Text.IndexOf(",") > 0)
e.Row.Cells[iCol].Text = e.Row.Cells[iCol].Text.Substring(0, e.Row.Cells[iCol].Text.IndexOf(","));
}
e.Row.Cells[34].CssClass = "cellTableColHeader";
e.Row.Cells[34].Text = "Coût/jour";
e.Row.Cells[35].CssClass = "cellTableColHeader";
e.Row.Cells[35].Text = "Total";
e.Row.Cells[36].CssClass = "cellTableColHeader";
e.Row.Cells[36].Text = "Coût Total";
e.Row.Cells[37].CssClass = "cellTableColHeader";
e.Row.Cells[37].Text = "Action";
}
}
}
} |
Je vous remercie par avance pour votre aide précieuse.
BON WEEKEND !