L
lcl800
Unregistered / Unconfirmed
GUEST, unregistred user!
<%@page clienttarget="downlevel" %>
<%@import namespace="system.Data"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
<title>新建网页 1</title>
<script language=vb runat=server>
dim ds as new dataset
dim dt as new dataTable("score")
dim Dv as dataView
sub page_load(source as object,E as Eventargs)
dt.columns.add(new datacolumn("ksbh",gettype(string)))
dt.columns.add(new datacolumn("kmmc",gettype(string)))
dt.columns.add(new datacolumn("a1",gettype(int32)))
dt.columns.add(new datacolumn("a2",gettype(int32)))
ds.tables.add(dt)
dim ksbh() as integer={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}
dim kmmc() as string={"英语","英语","英语","英语","英语"}
dim a1() as integer={32,27,22,23}
dim a2() as integer={25,32,27,22,23}
dim i as integer
dim dr as datarow
for i=0 to 3
dr=dt.newrow()
dr(0)=ksbh(i)
dr(1)=kmmc(i)
dr(2)=a1(i)
dr(3)=a2(i)
dt.rows.add(dr)
next i
dr=dt.newrow()
dr(0)="6"
dr(1)="csdf"
dr(2)=12
dr(3)=22
dt.rows.add(dr)
dr=dt.newrow()
dr(0)="7"
dr(1)="csdf"
dr(2)=12
dr(3)=22
dt.rows.add(dr)
dv=New dataview(Dt)
dv.AllowNew = true
dv.sort="ksbh"
if not Ispostback then
dg.datasource=dv
dg.databind()
end if
end sub
sub gridedit(Sender as object,E as DatagridCommandEventArgs)
dg.edititemindex=E.item.itemindex
dg.datasource=dv
dg.databind()
end sub
sub gridcancel(Sender as object,E as DatagridCommandEventArgs)
dg.edititemindex=-1
dg.datasource=dv
dg.databind
end sub
sub gridupdate(Sender as object,E as DatagridCommandEventArgs)
dim mykmmc as string=e.item.cells(1).text
dim txtkmmc as textbox=ctype(e.item.cells(2).controls(0),textbox)
dim kmmc as string=txtkmmc.text
dim txta1 as textbox=ctype(e.item.cells(2).controls(0),textbox)
dim aa1 as integer=cint(txta1.text)
dim txta2 as textbox=ctype(e.item.cells(3).controls(0),textbox)
dim aa2 as integer=cint(txta2.text)
dim txtbh as textbox=ctype(e.item.cells(0).controls(0),textbox)
dim bh as integer=cint(txtbh.text)
dv.rowfilter="ksbh=" &
bh
if dv.count>0 then
dv.delete(0)
end if
dv.rowfilter=""
dim dr as datarow
dr=dt.Newrow()
dr(0)=bh
dr(1)=mykmmc
dr(2)=aa1
dr(3)=aa2
dt.rows.Add(dr)
dt.acceptchanges
ds.acceptchanges
dg.edititemIndex=-1
dg.datasource=dv
dg.databind()
end sub
sub griddelete(Sender as object,E as DatagridCommandEventArgs)
dg.edititemindex=E.item.itemindex
end sub
sub scoadd(sender As Object, e As EventArgs)
if page.isvalid then
dim ksbh as string=txtksbh.text
dim A1 as string=txta1.text
dim A2 as string=txta2.text
dim dr as datarow
dr=dt.newrow()
dr(0)=ksbh
dr(1)=request.cookies("subject")("subjectname")
dr(2)=a1
dr(3)=a2
dt.rows.add(dr)
dt.acceptchanges
ds.acceptchanges
dg.datasource=dv
dg.databind()
end if
end sub
</script>
</head>
<body>
<form runat=server>
<asp:datagrid
id=dg
runat=server
autogeneratecolumns=False
oneditcommand="gridedit"
oncancelcommand="gridcancel"
onupdatecommand="gridupdate"
ondeletecommand="griddelete"
datakeyfield="ksbh"
>
<columns>
<asp:BoundColumn DataField="ksbh" HeaderText="学号" />
<asp:BoundColumn DataField="kmmc" HeaderText="学号" />
<asp:BoundColumn DataField="A1" HeaderText="题一" />
<asp:BoundColumn DataField="A2" HeaderText="题二" />
<asp:EditCommandColumn headertext="操作" EditText="编辑" CancelText="取消" UpdateText="修改"/>
<asp:ButtonColumn ButtonType=PushButton text="删除" CommandName="delete"/>
</columns>
</asp:datagrid>
<asp:TextBox ID="txtksbh" runat=server/>
<asp:RegularExpressionValidator ID="rgvksbh" Runat=server ControlToValidate=txtksbh validationexpression="^/d{15}$" >袋号是15位数
</asp:RegularExpressionValidator>
<asp:TextBox ID="txta1" runat=server/>
<asp:RangeValidator id="rana1" runat=server controltovalidate="txta1" type=Integer MaximumValue="10" minimumvalue="0">请输入正确分数</asp:RangeValidator>
<asp:TextBox ID="txta2" runat=server/>
<asp:RangeValidator id="rana2" runat=server controltovalidate="txta1" type=Integer MaximumValue="10" minimumvalue="0">请输入正确分数</asp:RangeValidator>
<asp:Button id="butadd" runat=server text="增加" onclick="scoadd" />
</form>
</body>
</html>
<%@import namespace="system.Data"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
<title>新建网页 1</title>
<script language=vb runat=server>
dim ds as new dataset
dim dt as new dataTable("score")
dim Dv as dataView
sub page_load(source as object,E as Eventargs)
dt.columns.add(new datacolumn("ksbh",gettype(string)))
dt.columns.add(new datacolumn("kmmc",gettype(string)))
dt.columns.add(new datacolumn("a1",gettype(int32)))
dt.columns.add(new datacolumn("a2",gettype(int32)))
ds.tables.add(dt)
dim ksbh() as integer={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}
dim kmmc() as string={"英语","英语","英语","英语","英语"}
dim a1() as integer={32,27,22,23}
dim a2() as integer={25,32,27,22,23}
dim i as integer
dim dr as datarow
for i=0 to 3
dr=dt.newrow()
dr(0)=ksbh(i)
dr(1)=kmmc(i)
dr(2)=a1(i)
dr(3)=a2(i)
dt.rows.add(dr)
next i
dr=dt.newrow()
dr(0)="6"
dr(1)="csdf"
dr(2)=12
dr(3)=22
dt.rows.add(dr)
dr=dt.newrow()
dr(0)="7"
dr(1)="csdf"
dr(2)=12
dr(3)=22
dt.rows.add(dr)
dv=New dataview(Dt)
dv.AllowNew = true
dv.sort="ksbh"
if not Ispostback then
dg.datasource=dv
dg.databind()
end if
end sub
sub gridedit(Sender as object,E as DatagridCommandEventArgs)
dg.edititemindex=E.item.itemindex
dg.datasource=dv
dg.databind()
end sub
sub gridcancel(Sender as object,E as DatagridCommandEventArgs)
dg.edititemindex=-1
dg.datasource=dv
dg.databind
end sub
sub gridupdate(Sender as object,E as DatagridCommandEventArgs)
dim mykmmc as string=e.item.cells(1).text
dim txtkmmc as textbox=ctype(e.item.cells(2).controls(0),textbox)
dim kmmc as string=txtkmmc.text
dim txta1 as textbox=ctype(e.item.cells(2).controls(0),textbox)
dim aa1 as integer=cint(txta1.text)
dim txta2 as textbox=ctype(e.item.cells(3).controls(0),textbox)
dim aa2 as integer=cint(txta2.text)
dim txtbh as textbox=ctype(e.item.cells(0).controls(0),textbox)
dim bh as integer=cint(txtbh.text)
dv.rowfilter="ksbh=" &
bh
if dv.count>0 then
dv.delete(0)
end if
dv.rowfilter=""
dim dr as datarow
dr=dt.Newrow()
dr(0)=bh
dr(1)=mykmmc
dr(2)=aa1
dr(3)=aa2
dt.rows.Add(dr)
dt.acceptchanges
ds.acceptchanges
dg.edititemIndex=-1
dg.datasource=dv
dg.databind()
end sub
sub griddelete(Sender as object,E as DatagridCommandEventArgs)
dg.edititemindex=E.item.itemindex
end sub
sub scoadd(sender As Object, e As EventArgs)
if page.isvalid then
dim ksbh as string=txtksbh.text
dim A1 as string=txta1.text
dim A2 as string=txta2.text
dim dr as datarow
dr=dt.newrow()
dr(0)=ksbh
dr(1)=request.cookies("subject")("subjectname")
dr(2)=a1
dr(3)=a2
dt.rows.add(dr)
dt.acceptchanges
ds.acceptchanges
dg.datasource=dv
dg.databind()
end if
end sub
</script>
</head>
<body>
<form runat=server>
<asp:datagrid
id=dg
runat=server
autogeneratecolumns=False
oneditcommand="gridedit"
oncancelcommand="gridcancel"
onupdatecommand="gridupdate"
ondeletecommand="griddelete"
datakeyfield="ksbh"
>
<columns>
<asp:BoundColumn DataField="ksbh" HeaderText="学号" />
<asp:BoundColumn DataField="kmmc" HeaderText="学号" />
<asp:BoundColumn DataField="A1" HeaderText="题一" />
<asp:BoundColumn DataField="A2" HeaderText="题二" />
<asp:EditCommandColumn headertext="操作" EditText="编辑" CancelText="取消" UpdateText="修改"/>
<asp:ButtonColumn ButtonType=PushButton text="删除" CommandName="delete"/>
</columns>
</asp:datagrid>
<asp:TextBox ID="txtksbh" runat=server/>
<asp:RegularExpressionValidator ID="rgvksbh" Runat=server ControlToValidate=txtksbh validationexpression="^/d{15}$" >袋号是15位数
</asp:RegularExpressionValidator>
<asp:TextBox ID="txta1" runat=server/>
<asp:RangeValidator id="rana1" runat=server controltovalidate="txta1" type=Integer MaximumValue="10" minimumvalue="0">请输入正确分数</asp:RangeValidator>
<asp:TextBox ID="txta2" runat=server/>
<asp:RangeValidator id="rana2" runat=server controltovalidate="txta1" type=Integer MaximumValue="10" minimumvalue="0">请输入正确分数</asp:RangeValidator>
<asp:Button id="butadd" runat=server text="增加" onclick="scoadd" />
</form>
</body>
</html>