grid view中模式对话框的实现
来源:互联网 发布:八爪网络怎么样 编辑:程序博客网 时间:2024/05/29 03:11
在gridview中的一行点击按钮时弹出模式对话框的效果可以通过div来实现,使用到以下两个方法
<script type="text/javascript">
function locking(){
document.all.ly.style.display="block";
document.all.ly.style.width=document.body.clientWidth;
document.all.ly.style.height=document.body.clientHeight;
document.all.Layer2.style.display='block';
}
function Lock_CheckForm(theForm){
document.all.ly.style.display='none';document.all.Layer2.style.display='none';
return false;
}
具体的页面源代码如下:
aspx文件:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default8.aspx.cs" Inherits="Default8" %>
<!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 runat="server">
<title>无标题页</title>
<script type="text/javascript">
function locking(){
document.all.ly.style.display="block";
document.all.ly.style.width=document.body.clientWidth;
document.all.ly.style.height=document.body.clientHeight;
document.all.Layer2.style.display='block';
}
function Lock_CheckForm(theForm){
document.all.ly.style.display='none';document.all.Layer2.style.display='none';
return false;
}
</script>
<style type ="text/css">
.bodys
{
postion:absolute;
width:100px;
height:200px;
top: 55px;
left:50px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<div id="ly" style="position: absolute; top: 0px; filter: alpha(opacity=60); background-color: #777;
z-index: 2; left: 0px; display: none;">
</div>
<div id="Layer2" align="center" style="position: absolute; z-index: 3; left: expression((document.body.offsetWidth-540)/2); top: expression((document.body.offsetHeight-170)/2);
background-color: #fff; display: none;" >
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" OnRowCommand="GridView1_RowCommand" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnDataBound="GridView1_DataBound" OnRowDataBound="GridView1_RowDataBound" Width="470px">
<Columns>
<asp:TemplateField HeaderText="prd_web" SortExpression="prd_web">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("prd_web") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("prd_web") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="prd_address" SortExpression="prd_address">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("prd_address") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("prd_address") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="prd_id" SortExpression="prd_id">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("prd_id") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("prd_id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="prd_name" SortExpression="prd_name">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("prd_name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("prd_name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName=""
Text="按钮"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField></asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="get_Producer_List"
TypeName="Producer_DA"></asp:ObjectDataSource>
<table style="width: 324px">
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td style="height: 21px">
</td>
<td style="height: 21px">
</td>
<td style="height: 21px">
</td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox><br />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
cs文件:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default8 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Button1.Attributes.Add("onclick", "Lock_CheckForm()");
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
//div1.Visible = true;
Int32 index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
Label lbl = (Label)row.FindControl("Label1");
TextBox1.Text = lbl.Text;
}
protected void Button1_Click(object sender, EventArgs e)
{
//div1.Visible = false;
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void GridView1_DataBound(object sender, EventArgs e)
{
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//TextBox tb = (TextBox)e.Row.FindControl("TextBox5");
LinkButton lb = (LinkButton)e.Row.FindControl("LinkButton1");
if (e.Row.RowIndex != -1)
{
//tb.Text =e.Row.RowIndex.ToString();
lb.CommandArgument = e.Row.RowIndex.ToString();
lb.Attributes.Add("onclick", "locking()");
}
}
}
- grid view中模式对话框的实现
- Dll中实现模式对话框
- VC++中模式对话框和非模式对话框的区别
- VC++中模式对话框和非模式对话框的区别
- grid中实现换行
- 存储过程实现Grid View分页
- 用JS实现模式对话框的方法
- 模式对话框PopupWindow实现Dialog的功能
- silverlight 下的模式对话框实现
- android 自定义View【2】对话框取色&色盘取色的实现
- Grid View
- Grid View
- Grid View
- C#中对话框的开发模式
- MFC 实现在调用非模式对话框时,view不可响应鼠标操作
- 在Java applet中如何实现一个模式对话框?
- List,grid...view所遇到的坑
- 转载:grid中实现换行
- 浅析C#的事件处理和自定义事件(转)
- radix sort &&bucket sort
- .Net 下数据库操作类库
- 什么玩意
- GB与Unicode互换函数
- grid view中模式对话框的实现
- 学会挣小钱
- System.NullReferenceException: 未将对象引用设置到对象的实例。
- Winmail服务启动失败原因分析
- 动态生成文本提示下拉框
- 化妆品行业的PPG——妆点网
- 全国最具竞争力的珠宝管理软件
- 成功六句话
- lucene结果集的分页处理(百度 分页 方式)(转)