editable datagrid

csharp France
  • 9 years ago

    hi!

    I have an editable datagrid with 2 columns one is contry(it is not editable) the other one is an editable column with amount (float)...

    I would to know,how can i update my grid..I don't how can i pick the datas of textbox in datagrid...

    here is my Datagrid:

    <Columns>

    <asp:templatecolumn>
    <itemstyle Width="126px"></itemstyle>
    <itemtemplate>
    <div noWrap STYLE="cursor: hand; width: 61px; overflow: hidden; text-overflow: ellipsis"><span title='<%#DataBinder.Eval(Container.DataItem,"CODE_PAYS").ToString()%>'><%#DataBinder.Eval(Container.DataItem, "CODE_PAYS").ToString()%></span></div>
    </itemtemplate>
    </asp:templatecolumn>
    <asp:TemplateColumn>
    <ItemTemplate>
    <table cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td valign="bottom" width="120px" align="center">

    <tb:TextBoxEntier id="PrixGasoil" Width="95px" runat="server" class="bigInputBold" Text='<%# DataBinder.Eval(Container.DataItem,"MONTANT").ToString() %>'/>
    </td>
    </tr>
    </table>

    </ItemTemplate>
    <ItemStyle width="120px"/>
    </asp:TemplateColumn>
    </Columns>
     

    This is my query:

    private static String UPDATE_PAYS_GASOIL =
    "UPDATE PRIXGO_MOIS SET " +
    " CODE_PAYS= @CODE_PAYS , " +
    " MONTANT = @MONTANT, " +
    " AAAAMM= @AAAAMM " +
    "WHERE ID_PRIXGO=@ID_PRIXGO";

    #region updatePays
    public static DataSet updatePays(String sCodePays, float fMontant, String sAaaamm, TxHelper oTxHelper)
    {
    try
    {
    SqlParameter[] sqlParameters = new SqlParameter[3];
    sqlParameters[0] = (
    SqlParameter)AddInParameter("CODE_PAYS", sCodePays);
    sqlParameters[1] = (
    SqlParameter)AddInParameter("MONTANT", fMontant);
    sqlParameters[2] = (
    SqlParameter)AddInParameter("AAAAMM", sAaaamm);
    return ExecuteQueryDataSet(UPDATE_PAYS_GASOIL, sqlParameters, oTxHelper);
    }
    catch (SqlException exp)
    {
    ErrorHandler.HandleError(exp, null);
    throw new UtilException(String.Concat(exp.TargetSite, " : ", exp.Message), "err.sqlexception.not.found");
    }
    catch (Exception exp)
    {
    ErrorHandler.HandleError(exp, null);
    throw new UtilException(String.Concat(exp.TargetSite, " : ", exp.Message));
    }
    }
    #endregion

    Then this my validation button:

    protected void ValiderPrix_Btn_Click(object sender, EventArgs e)
    {
    try
    {
    FacturationCmd oFacturationCmd = new FacturationCmd();
     
    oFacturationCmd.iAction =
    CommandConst.iCmdParametreUpdatePaysGasoil;
    oFacturationCmd.sCodePays = oFacturationCmd.sCodePays;
    oFacturationCmd.sAaaamm = AnneeEnCours_Label.Text;
    //oFacturationCmd.fMontant = ;
     
     
    oFacturationCmd.execute(IsolationLevel.ReadUncommitted);
    loadPaysPrixDs();
    }
    catch (UtilException ex)
    {
    ErrorHandler.HandleError(ex, null);
    showError(GetResourceError(ex.Code));
    }
    catch (Exception ex)
    {
    ErrorHandler.HandleError(ex, null);
    showError(ex.Message);
    }

     

    Advance thanks for your help,pls let me know if u don't understand...

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It works on my machine.” - Anonymous