ASP.NET中的附件系统 [英] Attandance system in ASP.NET
本文介绍了ASP.NET中的附件系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为学生制作在线考勤系统我有一个gridview,其中我填写每个月的出席率,即每个单元格中的'a'或'p',但现在我想要更改单元格的数据,如果它显示然后点击网格它显示p但是没有到达那个位置
我的代码如下:
我的尝试:
< pre>< div id =datagridstyle =overflow:scroll; height:400px; width:980px;>
< asp:GridView ID =dgvrouteplanheadrunat =server
AutoGenerateColumns =true
Width =100%
DataKeyNames =Name
EmptyDataText =找不到记录!!
CellPadding =4ForeColor =#333333OnRowDataBound =dgvrouteplanhead_RowDataBound>
< RowStyle BackColor =#E3EAEB/>
< EmptyDataRowStyle CssClass =gvEmpty/>
< FooterStyle BackColor =#1C5E55Font-Bold =TrueForeColor =White/>
< PagerStyle BackColor =#666666ForeColor =WhiteHorizontalAlign =Center/>
< SelectedRowStyle BackColor =#C5BBAFFont-Bold =TrueForeColor =#333333/>
< HeaderStyle BackColor =#1C5E55Font-Bold =TrueForeColor =White/>
< EditRowStyle BackColor =#7C6F57/>
< AlternatingRowStyle BackColor =White/>
< / asp:GridView>
< / div>
返回代码获取所有数据在数据表中
dsattan.Tables [0] .Rows.Add(dsatt.Tables [0] .Rows [0] [RegnNo ] .ToString(),regesno,dsatt.Tables [0] .Rows [0] [Name]。ToString(),dsatt.Tables [0] .Rows [0] [a1]。ToString(), dsatt.Tables [0] .Rows [0] [a2]。ToString(),dsatt.Tables [0] .Rows [0] [a3]。ToString(),dsatt.Tables [0] .Rows [0] [a4]。ToString(),dsatt.Tables [0] .Rows [0] [a5]。ToString(),dsatt.Tables [0] .Rows [0] [a6] .ToString(),dsatt.Tables [0] .Rows [0] [a7]。ToString(),dsatt.Tables [0] .Rows [0] [a8]。ToString(),dsatt.Tables [0] .Rows [0] [a9]。ToString(),dsatt.Tables [0] .Rows [0] [a10]。ToString(),dsatt.Tables [0] .Rows [0] [a11]。ToString(),dsatt.Tables [0] .Rows [0] [a12]。ToString(),dsatt.Tables [0] .Rows [0] [a13]。ToString( ),dsatt.Tables [0] .Rows [0] [a14]。ToString(),dsatt.Tables [0] .Rows [0] [a15]。ToString(),dsatt.Tables [0] .Rows [0] [a16]。ToString(),dsatt.Tables [0] .Rows [ 0] [a17]。ToString(),dsatt.Tables [0] .Rows [0] [a18]。ToString(),dsatt.Tables [0] .Rows [0] [a19]。 ToString(),dsatt.Tables [0] .Rows [0] [a20]。ToString(),dsatt.Tables [0] .Rows [0] [a21]。ToString(),dsatt.Tables [ 0] .Rows [0] [a22]。ToString(),dsatt.Tables [0] .Rows [0] [a23]。ToString(),dsatt.Tables [0] .Rows [0] [ a24]。ToString(),dsatt.Tables [0] .Rows [0] [a25]。ToString(),dsatt.Tables [0] .Rows [0] [a26]。ToString() ,dsatt.Tables [0] .Rows [0] [a27]。ToString(),dsatt.Tables [0] .Rows [0] [a28]。ToString(),dsatt.Tables [0]。行[0] [a29]。ToString(),dsatt.Tables [0] .Rows [0] [a30]。ToString(),dsatt.Tables [0] .Rows [0] [a31 ] .ToString());
dgvrouteplanhead.DataSource = dsattan.Tables [0];
dgvrouteplanhead.DataBind();
解决方案
参考这个
< html xmlns =http://www.w3.org/1999/xhtml>
< head runat =server>
< script src =https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js>< / script>
< script>
(function(){
var grid = document.getElementById('<%= GridView1.ClientID%>');
('td',grid).on('click',function(){
var current = this.innerText.toLowerCase();
if(current =='a')
this.innerText ='P';
if(current =='p')
this.innerText ='A';
});
});
< / script>
< / head>
< body>
< form id =form1runat =server>
< asp:GridView ID =GridView1runat =server>< / asp:GridView>
< / form>
< / body>
< / html>
protected void Page_Load(对象发送者,EventArgs e)
{
if(!Page.IsPostBack){
DataTable dt = new DataTable();
dt.Columns.Add(Col1);
dt.Columns.Add(Col2);
dt.Columns.Add(Col3);
dt.Rows.Add(A,A,P);
dt.Rows.Add(A,P,P);
dt.Rows.Add(P,A,P);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
demo:小提琴 - 桌面版本 [ ^ 一>
i want to make online attendance system for students i had a gridview in which i populate all the attendance of month i.e 'a' or 'p' in each cell but now i want to change the data of cell like if it show a then on click of grid it show p but doesnot get at that position
my code is as follows :
What I have tried:
<pre><div id="datagrid" style="overflow:scroll; height:400px; width:980px; "> <asp:GridView ID="dgvrouteplanhead" runat="server" AutoGenerateColumns="true" Width="100%" DataKeyNames="Name" EmptyDataText="No record found !!" CellPadding="4" ForeColor="#333333" OnRowDataBound="dgvrouteplanhead_RowDataBound"> <RowStyle BackColor="#E3EAEB" /> <EmptyDataRowStyle CssClass="gvEmpty" /> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#7C6F57" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> </div>
back code in get all data in datatable
dsattan.Tables[0].Rows.Add(dsatt.Tables[0].Rows[0]["RegnNo"].ToString(), regesno, dsatt.Tables[0].Rows[0]["Name"].ToString(), dsatt.Tables[0].Rows[0]["a1"].ToString(), dsatt.Tables[0].Rows[0]["a2"].ToString(), dsatt.Tables[0].Rows[0]["a3"].ToString(), dsatt.Tables[0].Rows[0]["a4"].ToString(), dsatt.Tables[0].Rows[0]["a5"].ToString(), dsatt.Tables[0].Rows[0]["a6"].ToString(), dsatt.Tables[0].Rows[0]["a7"].ToString(), dsatt.Tables[0].Rows[0]["a8"].ToString(), dsatt.Tables[0].Rows[0]["a9"].ToString(), dsatt.Tables[0].Rows[0]["a10"].ToString(), dsatt.Tables[0].Rows[0]["a11"].ToString(), dsatt.Tables[0].Rows[0]["a12"].ToString(), dsatt.Tables[0].Rows[0]["a13"].ToString(), dsatt.Tables[0].Rows[0]["a14"].ToString(), dsatt.Tables[0].Rows[0]["a15"].ToString(), dsatt.Tables[0].Rows[0]["a16"].ToString(), dsatt.Tables[0].Rows[0]["a17"].ToString(), dsatt.Tables[0].Rows[0]["a18"].ToString(), dsatt.Tables[0].Rows[0]["a19"].ToString(), dsatt.Tables[0].Rows[0]["a20"].ToString(), dsatt.Tables[0].Rows[0]["a21"].ToString(), dsatt.Tables[0].Rows[0]["a22"].ToString(), dsatt.Tables[0].Rows[0]["a23"].ToString(), dsatt.Tables[0].Rows[0]["a24"].ToString(), dsatt.Tables[0].Rows[0]["a25"].ToString(), dsatt.Tables[0].Rows[0]["a26"].ToString(), dsatt.Tables[0].Rows[0]["a27"].ToString(), dsatt.Tables[0].Rows[0]["a28"].ToString(), dsatt.Tables[0].Rows[0]["a29"].ToString(), dsatt.Tables[0].Rows[0]["a30"].ToString(), dsatt.Tables[0].Rows[0]["a31"].ToString());
dgvrouteplanhead.DataSource = dsattan.Tables[0]; dgvrouteplanhead.DataBind();
解决方案
refer this
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script>
(function () { var grid = document.getElementById('<%= GridView1.ClientID%>');
('td', grid).on('click', function () { var current = this.innerText.toLowerCase(); if (current == 'a') this.innerText = 'P'; if (current == 'p') this.innerText = 'A'; }); }); </script> </head> <body> <form id="form1" runat="server"> <asp:GridView ID="GridView1" runat="server"></asp:GridView> </form> </body> </html>
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.Add("Col1"); dt.Columns.Add("Col2"); dt.Columns.Add("Col3"); dt.Rows.Add("A", "A", "P"); dt.Rows.Add("A", "P", "P"); dt.Rows.Add("P", "A", "P"); GridView1.DataSource = dt; GridView1.DataBind(); } }
demo: fiddle - table version[^]
这篇关于ASP.NET中的附件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文