The functions to be implemented are:
1. textbox "quantity used" is dynamically generated.
2. dynamically control the "available quantity" status in the background.
3. The input quantity for controlling "available quantity" cannot be greater than "available quantity ".
If the "available quantity" is greater than "available quantity", you cannot enter it !!!
Direct script implementation saves the trouble of submitting, checking, returning, and pop-up dialog boxes.
:
Front-end: < ASP: DataGrid ID = "Dgximu" Runat = "Server" Datakeyfield = "TID" Onupdatecommand = "Update" Oncancelcommand = "Cancel"
Oneditcommand = "Edit" Autogeneratecolumns = "False" Bordercolor = "# Cccccc" Borderstyle = "NONE" Borderwidth = "1px" Backcolor = "White" Cellpadding = "3"
Width = "100%" Allowpaging = "True" >
< Selecteditemstyle Font-bold = "True" Forecolor = "# F7f7f7" Backcolor = "# 738a9c" > </ Selecteditemstyle >
< Alternatingitemstyle Backcolor = "White" > </ Alternatingitemstyle >
< Itemstyle Forecolor = "Black" Backcolor = "White" > </ Itemstyle >
< Headerstyle Font-bold = "True" Forecolor = "#336699" Backcolor = "# E6eef7" > </ Headerstyle >
< Footerstyle Forecolor = "#336699" Backcolor = "# E6eef7" > </ Footerstyle >
< Columns >
< ASP: boundcolumn Datafield = "Whinno" Readonly = "True" Headertext = "Warehouse receiving Ticket No" >
< Headerstyle Width = "25%" > </ Headerstyle >
</ ASP: boundcolumn >
< ASP: boundcolumn Datafield = "Whindate" Readonly = "True" Headertext = "Warehouse receiving time" >
< Headerstyle Width = "25%" > </ Headerstyle >
</ ASP: boundcolumn >
< ASP: boundcolumn Datafield = "Warename" Headertext = "Database" >
< Headerstyle Width = "10%" > </ Headerstyle >
</ ASP: boundcolumn >
< ASP: boundcolumn Datafield = "Qtyky" Headertext = "Available quantity" >
< Headerstyle Width = "15%" > </ Headerstyle >
</ ASP: boundcolumn >
< ASP: boundcolumn Headertext = "Available quantity" >
< Headerstyle Width = "10%" > </ Headerstyle >
</ ASP: boundcolumn >
</ Columns >
</ ASP: DataGrid >
Add a piece of javascript: < Script Language = " Javascript " >
Function Isint (OBJ, strqtyky)
{
If (Event. keycode < 48 | Event. keycode > 57 )
{
Event. keycode = 0 ;
}
Else
{
// Original collection quantity
VaR Qtylyold
If (Obj. Value = "" )
Qtylyold = 0 ;
Else
Qtylyold = OBJ. value;
// Number of presses
VaR Qtylynew
Qtylynew = Parseint (event. keycode) - 48 ;
If (Qtylyold + Qtylynew) > Parseint (strqtyky ))
{
Event. keycode = 0 ;
}
}
}
</ Script >
Background: Private Void Dgximu_itemdatabound ( Object Sender, system. Web. UI. webcontrols. datagriditemeventargs E)
{
Try
{
Oasys. Public. Public objpub = New Oasys. Public. Public ();
For ( Int I = 0 ; I < Dgximu. Items. Count; I ++ )
{
// Primary Key Column
String Strtid = Dgximu. datakeys [I]. tostring ();
//Available quantity Column
Tablecell cellqtyky=Dgximu. items [I]. cells [4];
StringStrqtyky=Cellqtyky. text;
// Number of used Columns
Tablecell cellqtyly = Dgximu. items [I]. cells [ 5 ];
Cellqtyly. Controls. Clear ();
// Number of used columns-control readonly
Textbox TB = New Textbox ();
TB. cssclass = " Input_text " ;
TB. Width = 80 ;
TB. maxlength = 10 ;
TB. enableviewstate = True ;
TB. Attributes. Add ( " Onkeypress " , @" Isint (this, " + Strqtyky + " ) " );
Cellqtyly. Controls. Add (TB );
}
Objpub. Close ();
}
Catch (Exception ex)
{
Throw Ex;
}
}