aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="DynamicCreate.WebForm1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 100; LEFT: 23px; POSITION: absolute; TOP: 108px" runat="server" Text="Submit" Height="27px" Width="100px"></asp:Button>
<asp:Label id="Label4" style="Z-INDEX: 105; LEFT: 23px; POSITION: absolute; TOP: 197px" runat="server" Width="368px" EnableViewState="False"></asp:Label>
<asp:Label id="Label3" style="Z-INDEX: 104; LEFT: 23px; POSITION: absolute; TOP: 163px" runat="server" Width="368px" EnableViewState="False"></asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 23px; POSITION: absolute; TOP: 60px" runat="server" Width="86px" Height="19px"> TextBox2:</asp:Label>
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 23px; POSITION: absolute; TOP: 28px" runat="server" Width="86" Height="19"> TextBox1:</asp:Label>
<asp:Table id="Table1" style="Z-INDEX: 101; LEFT: 137px; POSITION: absolute; TOP: 80px" runat="server" Height="347px" Width="605px"></asp:Table>
</form>
</body></html>CS 文件 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;namespace DynamicCreate
{
public partial class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Button Button1; // Added by hand for access to the form.
protected System.Web.UI.HtmlControls.HtmlForm Form1; // Added by hand; will create instance in OnInit.
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2; protected void Page_Load(object sender, EventArgs e)
{ string strConnection = "user id=sa;password=borland;";
strConnection += "initial catalog=hr;Server=127.0.0.1;";
strConnection += "Connect Timeout=60";
SqlConnection connMain = new SqlConnection(strConnection);
connMain.Open();
String strSQL = "select a.id,a.name,sum(b.je) as je from (select* from dbo.v_hr_pay where pay_type_id = (select pay_type_id from v_hr_user where id = '0004' )) as a ";
strSQL +=" left join (select pay_id,abs(je) as je from dbo.v_hr_details where user_id ='0004' and date='2010-06-01' ) as b";
strSQL += " on a.id = b.pay_id group by a.id,a.name,a.xsxh order by right('000'+a.xsxh,3)";
DataSet ds_1 = new DataSet();
SqlDataAdapter dr_1 = new SqlDataAdapter(strSQL, connMain);
dr_1.Fill(ds_1,"hr_details_pay");
//ds_1.DataBind();
string aa = ds_1.Tables["hr_details_pay"].Rows.Count.ToString();
TableRow tr = new TableRow();
TableCell tc;
TableCell cell ;
TextBox tc1 ;
int i = 0;
for (i = 0; i < int.Parse(aa); i++)
{
if (i % 3 == 0)
tr = new TableRow();
tc = new TableCell();
cell = new TableCell();
tc1 = new TextBox();
tc1.ID = "id" + i.ToString();
tc1.Columns = 6 ;
tc1.Text = ds_1.Tables["hr_details_pay"].Rows[i][2].ToString();
tc.Text = ds_1.Tables["hr_details_pay"].Rows[i][1].ToString();
tr.Cells.Add(tc);
cell.Controls.Add(tc1);
tr.Cells.Add(cell);
if (i % 3 == 0)
Table1.Rows.Add(tr);
}
if (i % 3 != 0)
Table1.Rows.Add(tr);
}
}
}页面显示 岗位工资 13.00 职称津贴 0.00 其他津贴 0.00
独子津贴 0.00 其 他 0.00 奖 金
公 积 金 0.00 养 老 金 0.00 医 保 金
失 保 金 0.00 病 假 0.00 事 假
工 会 费 0.00 其 它 0.00第一我想实现 金额textbox(13.00、0.00 ) 全部为右对齐 代码 要如何改第二我想实现 修改 13..00 为 14.00 后 按回车 直接调到 职称津贴 这个 后面的 0.00 可以继续修改第三我想实现 只能输入数字,且只能输入2位小数
希望 那位大虾 指点 本人 是 初学 希望 能提供 代码 谢谢
<head>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 100; LEFT: 23px; POSITION: absolute; TOP: 108px" runat="server" Text="Submit" Height="27px" Width="100px"></asp:Button>
<asp:Label id="Label4" style="Z-INDEX: 105; LEFT: 23px; POSITION: absolute; TOP: 197px" runat="server" Width="368px" EnableViewState="False"></asp:Label>
<asp:Label id="Label3" style="Z-INDEX: 104; LEFT: 23px; POSITION: absolute; TOP: 163px" runat="server" Width="368px" EnableViewState="False"></asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 23px; POSITION: absolute; TOP: 60px" runat="server" Width="86px" Height="19px"> TextBox2:</asp:Label>
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 23px; POSITION: absolute; TOP: 28px" runat="server" Width="86" Height="19"> TextBox1:</asp:Label>
<asp:Table id="Table1" style="Z-INDEX: 101; LEFT: 137px; POSITION: absolute; TOP: 80px" runat="server" Height="347px" Width="605px"></asp:Table>
</form>
</body></html>CS 文件 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;namespace DynamicCreate
{
public partial class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.Button Button1; // Added by hand for access to the form.
protected System.Web.UI.HtmlControls.HtmlForm Form1; // Added by hand; will create instance in OnInit.
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2; protected void Page_Load(object sender, EventArgs e)
{ string strConnection = "user id=sa;password=borland;";
strConnection += "initial catalog=hr;Server=127.0.0.1;";
strConnection += "Connect Timeout=60";
SqlConnection connMain = new SqlConnection(strConnection);
connMain.Open();
String strSQL = "select a.id,a.name,sum(b.je) as je from (select* from dbo.v_hr_pay where pay_type_id = (select pay_type_id from v_hr_user where id = '0004' )) as a ";
strSQL +=" left join (select pay_id,abs(je) as je from dbo.v_hr_details where user_id ='0004' and date='2010-06-01' ) as b";
strSQL += " on a.id = b.pay_id group by a.id,a.name,a.xsxh order by right('000'+a.xsxh,3)";
DataSet ds_1 = new DataSet();
SqlDataAdapter dr_1 = new SqlDataAdapter(strSQL, connMain);
dr_1.Fill(ds_1,"hr_details_pay");
//ds_1.DataBind();
string aa = ds_1.Tables["hr_details_pay"].Rows.Count.ToString();
TableRow tr = new TableRow();
TableCell tc;
TableCell cell ;
TextBox tc1 ;
int i = 0;
for (i = 0; i < int.Parse(aa); i++)
{
if (i % 3 == 0)
tr = new TableRow();
tc = new TableCell();
cell = new TableCell();
tc1 = new TextBox();
tc1.ID = "id" + i.ToString();
tc1.Columns = 6 ;
tc1.Text = ds_1.Tables["hr_details_pay"].Rows[i][2].ToString();
tc.Text = ds_1.Tables["hr_details_pay"].Rows[i][1].ToString();
tr.Cells.Add(tc);
cell.Controls.Add(tc1);
tr.Cells.Add(cell);
if (i % 3 == 0)
Table1.Rows.Add(tr);
}
if (i % 3 != 0)
Table1.Rows.Add(tr);
}
}
}页面显示 岗位工资 13.00 职称津贴 0.00 其他津贴 0.00
独子津贴 0.00 其 他 0.00 奖 金
公 积 金 0.00 养 老 金 0.00 医 保 金
失 保 金 0.00 病 假 0.00 事 假
工 会 费 0.00 其 它 0.00第一我想实现 金额textbox(13.00、0.00 ) 全部为右对齐 代码 要如何改第二我想实现 修改 13..00 为 14.00 后 按回车 直接调到 职称津贴 这个 后面的 0.00 可以继续修改第三我想实现 只能输入数字,且只能输入2位小数
希望 那位大虾 指点 本人 是 初学 希望 能提供 代码 谢谢
解决方案 »
- asp.net 树形结构
- 怎么释放page.cache?
- ASP.NET做CrystalReport的问题
- 什么是活动目录??
- 采用 javascript 动态添加 input 文件,但是我想控制最多能添加 5 个或是某一数量,要如何修改这段javascript 代码呢,发帖必结,100 分
- 在asp.net C#中如何取控件?如何判斷CheckBox是否选中?
- td问题
- 在asp.net中如果显示指定目录下所有文件(包括文件名,大小,所在目录),文件夹下可能还有文件夹。
- 创建web应用程序出错.
- 请问ASP.NET支持语言有多少种?用那种较好?
- 大家设计的网站都是什么架构的?
- windows7 下iis6.0如何配置伪静态
textboxID.Attributes.Add( "style ", "text-align:right ")
TextBox1.Attribute.add("onkeypress","A('Button1')");
function A(button)
{
if(event.keyCode == 13)
{
event.keyCode = 9;
event.returnValue = false;
document.documentById("").focus();
}
} <asp:RegularExpressionValidator ID="rev13" runat="server"
ControlToValidate="txtElse" ErrorMessage="其他应为数值"
ValidationExpression="^[0-9]\d*\.\d{0,2}$|^\d*$"></asp:RegularExpressionValidator>
tc = new TableCell();
tc.ID = "Label"+ i.ToString();
cell = new TableCell();
tc1 = new TextBox();
tc1.ID = "id" + i.ToString();
tc1.Columns = 8;
tc1.CssClass = "c_textbox";
tc.CssClass = "c_label";
tc1.Text = ds_Yuan_payrollsEdit.Tables["T_Yuan_payrollsEdit"].Rows[i][2].ToString();
tc.Text = ds_Yuan_payrollsEdit.Tables["T_Yuan_payrollsEdit"].Rows[i][1].ToString() + ": ";
tc1.Attributes.Add("onkeydown", "if(event.keyCode==13)event.keyCode=9");
tr.Cells.Add(tc);
cell.Controls.Add(tc1);
tr.Cells.Add(cell);
这个方法实现的 可 0-9 外加小数点和保留2位小数 还是没解决
aspx 添加如下
function CheckInput(val) {
//Response.Write(event.keyCode)
//alert(event.keyCode);
if (event.keyCode == 13)
event.keyCode = 9;
//判断输入是否为0-9 (小键盘和大键盘)*2
else if ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105))
return true;
//判断输入的 是否是 .(主键盘和小键盘)*2 Home End delete left right backspace
else if (event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 190 || event.keyCode == 35 || event.keyCode == 36 || event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 110 )
return true;
else
return false;
}
cs 修改如下 if (strCommand == "Edit")
{
//权限查询
publicFunction pFunction = new publicFunction(); //获得数据表
DataTable T_Yuan_payrolls = (DataTable)Session["T_Yuan_payrolls"];
String Edit_date = T_Yuan_payrolls.Rows[intRowsIndex]["Date"].ToString();
String Edit_Name = T_Yuan_payrolls.Rows[intRowsIndex]["Name"].ToString();
//建立数据源
Yuan_PayrollsEdit yuan_payrollsEdit = new Yuan_PayrollsEdit();
DataSet ds_Yuan_payrollsEdit = yuan_payrollsEdit.GetDataSet(Edit_date,Edit_Name);
string aa = ds_Yuan_payrollsEdit.Tables["T_Yuan_payrollsEdit"].Rows.Count.ToString();
TableRow tr = new TableRow();
TableCell tc;
TableCell cell;
TextBox tc1;
int i = 0;
for (i = 0; i < int.Parse(aa); i++)
{
if ( i == 0)
{
tr = new TableRow();
//tr = new TableRow();
tc = new TableCell();
tc.ID = "Labeltop";
cell = new TableCell();
Label tcc = new Label();
Label tcc1 = new Label();
tcc.ID = "Tlbtop";
tc.Text = Edit_date;
tcc.Text = Edit_Name.Remove(0, 6);
tcc1.Text = aa;
tcc1.Visible = false;
tc.CssClass = "c_label";
tcc.CssClass = "c_label";
tr.Cells.Add(tc);
cell.Controls.Add(tcc);
cell.Controls.Add(tcc1);
tr.Cells.Add(cell);
Table1.Rows.Add(tr);}
if (i % 3 == 0 )
tr = new TableRow();
tc = new TableCell();
tc.ID = "Label"+ i.ToString();
cell = new TableCell();
tc1 = new TextBox();
tc1.ID = "id" + i.ToString();
tc1.Columns = 8;
tc1.CssClass = "c_textbox";
tc.CssClass = "c_label";
tc1.Text = ds_Yuan_payrollsEdit.Tables["T_Yuan_payrollsEdit"].Rows[i][2].ToString();
tc.Text = ds_Yuan_payrollsEdit.Tables["T_Yuan_payrollsEdit"].Rows[i][1].ToString() + ": ";
//tc1.Attributes.Add("onkeydown", "if(event.keyCode==13)event.keyCode=9");
tc1.Attributes.Add("onkeydown", "return CheckInput(this.value)");
tr.Cells.Add(tc);
cell.Controls.Add(tc1);
tr.Cells.Add(cell);
if (i % 3 == 0)
{
Table1.Rows.Add(tr);
}
}
if (i % 3 != 0)
Table1.Rows.Add(tr);
}}
这个解决 谢谢