Can't generate onchange evengt code for datagrid form

Discussion in 'ASP .Net Web Controls' started by chumley, Jan 15, 2010.

  1. chumley

    chumley Guest

    I'm having trouble generating onchange event code for a simple order
    form housed in a datagrid.
    This takes product items from sql database, whereas user can enter
    quantity (originally set to 25) of cards they want to order (the
    textbox id is txtQty). if they order 50 (so if they order 25 to 49,
    the price would stay the same for the lot), the subtotal for that
    given product will change another 15 dollars greater., so the formula
    for the price wouldnt be product * price, but "if qty = qty + 25 then
    subtotal = price + 15". Then the button click event would add the
    subtotals to a grand total.
    I cannot coordinate the adequate javascript that would fit with this
    type of scenario, given that this is all predicated on each product
    coming from the database;i'm wondering if there is another good source
    i can be directed to that would show helper functions in the code
    behind or header subs to calculate the onchange (or textOnchange)
    event of the textbox.

    <form name="mydgrid" runat="server">
    <asp:DataGrid id="dgProducts" runat="server"
    AutoGenerateColumns="False" CellPadding="4"
    HeaderStyle-BackColor="teal"
    HeaderStyle-ForeColor="White"
    HeaderStyle-HorizontalAlign="Center"
    Font-Name="Trebuchet MS"
    HeaderStyle-Font-Bold="True"
    ShowFooter="true"
    ShowHeader="true"

    >


    <Columns>
    <asp:BoundColumn HeaderText="ID" DataField="pID" />
    <asp:BoundColumn HeaderText="Name" DataField="proname" />

    <asp:TemplateColumn HeaderText="QTY"><ItemStyle
    BackColor=GhostWhite />

    <ItemTemplate>

    <asp:TextBox ID="txtQty" name="txtQty"
    runat="server" size="5px" Text='25' onChange="qtycg(this.form)">

    </asp:TextBox>

    </ItemTemplate>

    </asp:TemplateColumn>

    <asp:BoundColumn HeaderText="Price<br>1 Ink</br>"
    DataField="UnitPrice"
    ItemStyle-HorizontalAlign="Right"
    DataFormatString="{0:$#,###.##}" />
    <asp:BoundColumn HeaderText="Price<br>2 Ink</br>"
    DataField="UnitPrice2C"
    ItemStyle-HorizontalAlign="Right"
    DataFormatString="{0:$#,###.##}" />


    <asp:TemplateColumn HeaderText="Subtotal">
    <ItemTemplate >
    <asp:TextBox id="SubTotal" Runat="server" Text='<%#
    DataBinder.Eval(Container.DataItem, "UnitPrice")%>'></asp:TextBox>

    </ItemTemplate>
    <FooterTemplate> <asp:Label id="lblGrandTotal" Runat="server"
    Text='Grand Total:'></asp:Label> <br></br>
    <asp:TextBox ID="Total" Runat="server"
    size="5px" onFocus="this.form.elements[0].focus()"></asp:TextBox>
    <br><asp:Button id=btnSave align=center CommandName="Save" Text=Save
    runat=server />
    <asp:Button ID="btnReset" align=center Text=Reset runat=server /
    ></br>

    </FooterTemplate>

    </asp:TemplateColumn>

    </Columns>
    </asp:DataGrid>
    </form>

    ThANKS IN advance for any help!
    chumley
    chumley, Jan 15, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brendan Vogt

    POSTING A FORM USING onchange

    Brendan Vogt, Aug 28, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    471
    Leon Jollans
    Aug 28, 2003
  2. Sweety
    Replies:
    6
    Views:
    4,047
    CBFalconer
    Apr 5, 2004
  3. IcemanUK
    Replies:
    0
    Views:
    454
    IcemanUK
    Sep 1, 2008
  4. Casey Hawthorne
    Replies:
    1
    Views:
    696
    Arne Vajhøj
    Mar 18, 2009
  5. Harlan Messinger
    Replies:
    2
    Views:
    2,280
    John Bell
    Mar 28, 2010
Loading...

Share This Page