最近在做一个网页界面,是人事考勤方面的,功能是填写一个部门多个员工的请假月报表,大概格式如下人员编码 姓名 出勤工日 小计 病假 事假 婚嫁 产假 摘要
001 张三 22 1 1 0 0 0 2010-11-25请假一天
002 李四 22 0 0 0 0 0 其中,我的想法是从数据库中仅导出"人员编码"和"姓名"两列并且绑定在gridview控件中,"人员编码"列作为超链接列,而后面的需要填写数据的几个列不用绑定,然后通过点击点击"人员编码"列弹出模式窗口,在模式窗口中填入后面几列数据,提交后关闭模式窗口,并将填写的数据返回到点击的那一行的后面几个列的网格中,但是在提交后不知怎样获取几个返回值;另外,今天尝试使用gridview添加编辑列的方法来解决这个问题,也一直没有解决好,老是无法获取在编辑状态时各个被编辑的网格中的文本框的值,请各位一并赐教,或者提供更好的思路,谢谢!涉及的代码如下:前台:设置超链接列
<asp:GridView ID="GV" runat="server" AutoGenerateColumns="False" Height="1px"
Style="z-index: 100; left: 8px; position: absolute; top: 8px" Width="800px" CellPadding="4" Font-Size="Small" ForeColor="#333333">
<Columns>
<asp:TemplateField HeaderText="人员编码">
<ItemTemplate>
<a href="<%# GetUserPageScp(Eval("人员编码")) %>"><%#Eval("人员编码")%></a>
</ItemTemplate>
<ItemStyle Width="80px" />
</asp:TemplateField>
<asp:BoundField DataField="姓名" HeaderText="姓名" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField HeaderText="出勤工日" >
<ItemStyle Width="15px" />
</asp:BoundField>
<asp:BoundField HeaderText="小计" >
<ItemStyle Width="15px" />
</asp:BoundField>
<asp:BoundField HeaderText="病假" >
<ItemStyle Width="15px" Wrap="True" />
</asp:BoundField>
<asp:BoundField HeaderText="事假">
<ItemStyle Width="15px" />
</asp:BoundField>
<asp:BoundField HeaderText="婚假">
<ItemStyle Width="15px" />
</asp:BoundField>
<asp:BoundField HeaderText="产假">
<ItemStyle HorizontalAlign="Right" Width="15px" />
</asp:BoundField> <asp:BoundField HeaderText="摘要">
<ItemStyle Width="100px" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
后台:弹出模式窗口和传递参数
Protected Function GetuserPageScp(ByVal Rybm As String) As String
Return "javascript: window.showModalDialog('" + Me.Page.ResolveUrl("Rykqjl.aspx?Rybm=" + Rybm) + "','','dialogHeight:700px;dialogWidth:900px');"
End Function
001 张三 22 1 1 0 0 0 2010-11-25请假一天
002 李四 22 0 0 0 0 0 其中,我的想法是从数据库中仅导出"人员编码"和"姓名"两列并且绑定在gridview控件中,"人员编码"列作为超链接列,而后面的需要填写数据的几个列不用绑定,然后通过点击点击"人员编码"列弹出模式窗口,在模式窗口中填入后面几列数据,提交后关闭模式窗口,并将填写的数据返回到点击的那一行的后面几个列的网格中,但是在提交后不知怎样获取几个返回值;另外,今天尝试使用gridview添加编辑列的方法来解决这个问题,也一直没有解决好,老是无法获取在编辑状态时各个被编辑的网格中的文本框的值,请各位一并赐教,或者提供更好的思路,谢谢!涉及的代码如下:前台:设置超链接列
<asp:GridView ID="GV" runat="server" AutoGenerateColumns="False" Height="1px"
Style="z-index: 100; left: 8px; position: absolute; top: 8px" Width="800px" CellPadding="4" Font-Size="Small" ForeColor="#333333">
<Columns>
<asp:TemplateField HeaderText="人员编码">
<ItemTemplate>
<a href="<%# GetUserPageScp(Eval("人员编码")) %>"><%#Eval("人员编码")%></a>
</ItemTemplate>
<ItemStyle Width="80px" />
</asp:TemplateField>
<asp:BoundField DataField="姓名" HeaderText="姓名" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField HeaderText="出勤工日" >
<ItemStyle Width="15px" />
</asp:BoundField>
<asp:BoundField HeaderText="小计" >
<ItemStyle Width="15px" />
</asp:BoundField>
<asp:BoundField HeaderText="病假" >
<ItemStyle Width="15px" Wrap="True" />
</asp:BoundField>
<asp:BoundField HeaderText="事假">
<ItemStyle Width="15px" />
</asp:BoundField>
<asp:BoundField HeaderText="婚假">
<ItemStyle Width="15px" />
</asp:BoundField>
<asp:BoundField HeaderText="产假">
<ItemStyle HorizontalAlign="Right" Width="15px" />
</asp:BoundField> <asp:BoundField HeaderText="摘要">
<ItemStyle Width="100px" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
后台:弹出模式窗口和传递参数
Protected Function GetuserPageScp(ByVal Rybm As String) As String
Return "javascript: window.showModalDialog('" + Me.Page.ResolveUrl("Rykqjl.aspx?Rybm=" + Rybm) + "','','dialogHeight:700px;dialogWidth:900px');"
End Function
解决方案 »
- asp.net生成html该用哪种方法呀,大家都怎么做的?
- 购物网站的管理员登录如何设计的?
- socket与服务器端通信,求一解决方法。
- 关于file对象生成的问题,感觉不是很好弄,请大家指点迷津,谢谢!
- 奇怪的现象:用了验证控件后按钮失效!
- 怎样把一个项目放到别的项目中去???
- *******************请教如何取得一个字符串中的XXXXXXX****************
- 常规网络错误。 检查网络文档 --急,在线等
- 在实际项目中服务器端控件和客户端控件的选择?
- 各位高手,请问TREE组件如何用啊?
- 如何防止点击上传按钮fileupload自动刷新为空啊???因为我下面好要用到里面的信息!!
- 全站搜索,类似淘宝的搜索功能
在弹出层中写需要填的信息,点击弹出层的确定按钮式,执行js代码,将
数据填到gridview中
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title> <script language="javascript">
var object;
function ShowValue(currentObject)
{
object = currentObject;
document .getElementById ("myName").innerText = object.innerText;
document.getElementById ("mydiv").style .display = "block";
}
function MyConfirm()
{
var valueA = document.getElementById ("aValue").value ;
var valueB = document.getElementById ("bValue").value ;
object.parentElement.parentElement.children[1].innerText = valueA;
object.parentElement.parentElement.children[2].innerText = valueB;
document.getElementById ("mydiv").style .display = "none";
}
</script></head>
<body>
<form id="form1" runat="server">
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table>
<tr>
<th width="100px" align="center">
编辑
</th>
<th width="100px" align="center">
A的值
</th>
<th width="100px" align="center">
B的值
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="center">
<a href="#" onclick="ShowValue(this);">
<%#Eval("id") %></a>
</td>
<td align="center">
</td>
<td align="center">
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<br />
<br />
<br />
<div id="mydiv" visible ="false" style ="display :none ;">
<table>
<tr>
<td>
name:<label id="myName"></label>
</td>
</tr>
<tr>
<td>
a:<input id="aValue" type="text" />
</td>
</tr>
<tr>
<td>
b:<input id="bValue" type="text" />
</td>
</tr>
<tr>
<td>
<input type="button" value="确定" onclick="MyConfirm();" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
你的方法太棒了,能否将repeater控件替换成gridview并提供代码,谢谢!
<asp:TemplateField HeaderText="人员编码">
<ItemTemplate>
<a href="#" onclick="ShowValue(<%# GetUserPageScp(Eval("人员编码")) %>)><%#Eval("人员编码")%></a>
</ItemTemplate>
<ItemStyle Width="80px" />
</asp:TemplateField>
就这样,你试试