两个问题
一\ 利用div层嵌套作了一个多页栏分割对话框,每个页栏内可以放置控件
二、GridView 嵌入checkbox 想选中checkbox后,将GridView 中的row 返回给 多页栏其他层的text控件中现在的问题是 GridView的checkbox选中检测函数,不知道放在那里 会被其他层text控件接收到阿,而且还发现一个现象
利用div嵌套的层 只要buttion按下 当前页的控件就消失了 怎么回事啊 非常急啊这是前台页面代码
<script type="text/javascript">
<!--
/*第一种形式 第二种形式 更换显示样式*/
function setTab(name, cursel, n) {
for (i = 1; i <= n; i++) {
var menu = document.getElementById(name + i);
var con = document.getElementById("con_" + name + "_" + i);
document.getElementById("Contentbox").style.height = "0px";
if (i == cursel && menu.className == "w") {
menu.className = "hover";
con.style.display = "block";
opendiv();
} else { menu.className = "w";
con.style.display = "none";
}
}
}
function opendiv() {
var height = document.getElementById("Contentbox").offsetHeight;
if (height < 400) {
document.getElementById("Contentbox").style.height = (height + 5) + "px";
setTimeout("opendiv()", 10);
}
}
//-->
</script> <div id="Tab1">
<div class="Menubox">
<ul>
<li id="one1" onmouseover="setTab('one',1,4)">查找用户</li>
<li id="one2" onmouseover="setTab('one',2,4)">新建用户</li>
<li id="one3" onmouseover="setTab('one',3,4)">修改用户</li>
<li id="one4" onmouseover="setTab('one',4,4)">删除用户</li>
<li></li>
<li></li>
<li></li>
<li></li>
<li>
</li>
</ul>
</div>
<div class="Contentbox" id="Contentbox">
<div id="con_one_1" style="display: none">
<div runat="server" >
查找用户
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" AllowPaging="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="Button10" runat="server" Text="确定" onclick="Button10_Click" />
<asp:Button ID="Button11" runat="server" Text="取消" /> </div>
</div>
<div id="con_one_2" style="display: none">
<div>
新建用户 作为选项卡2<br/>
<asp:Label ID="Label6" runat="server" Text="用户名称 "></asp:Label>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><br/><br/>
<asp:Label ID="Label7" runat="server" Text="用户密码 "></asp:Label>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox><br /><br/>
<asp:Label ID="Label8" runat="server" Text="用户所属部门 "></asp:Label>
<asp:DropDownList ID="DropDownList3" runat="server"></asp:DropDownList><br /><br/>
<asp:Label ID="Label9" runat="server" Text="用户联系方式 "></asp:Label>
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox> <br /><br/>
<asp:Label ID="Label10" runat="server" Text="用户使用角色 "></asp:Label>
<asp:DropDownList ID="DropDownList4" runat="server"> </asp:DropDownList><br /><br/> <asp:Button ID="Button4" runat="server" Text="上一条记录" />
<asp:Button ID="Button5" runat="server" Text="下一条记录" />
<asp:Button ID="Button6" runat="server" Text="新建用户" /> </div>
</div>
<div id="con_one_3" style="display: none">
<div>
修改用户,作为选项卡3<br/>
<asp:Label ID="Label1" runat="server" Text="用户名称 "></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br/><br/>
<asp:Label ID="Label2" runat="server" Text="用户密码 "></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /><br/>
<asp:Label ID="Label3" runat="server" Text="用户所属部门 "></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList><br /><br/>
<asp:Label ID="Label4" runat="server" Text="用户联系方式 "></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <br /><br/>
<asp:Label ID="Label5" runat="server" Text="用户使用角色 "></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server"> </asp:DropDownList><br /><br/> <asp:Button ID="Button1" runat="server" Text="上一条记录" />
<asp:Button ID="Button2" runat="server" Text="下一条记录" />
<asp:Button ID="Button3" runat="server" Text="修改用户" /> </div>
</div>
</div>
</div></asp:Content>后台页面代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyAccess;
using System.Data;
using System.Data.OleDb;
using System.Collections;
using System.Data.SqlClient;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
public MyAccess.MyAccess myaccess_2= new MyAccess.MyAccess();
public static int ss1;
protected void Page_Load(object sender, EventArgs e)
{
myaccess_2.ConnDbForAcccess(@" Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = h:\device1\device.mdb");
DataSet myDataSet2 = myaccess_2.ReturnDataSet("SELECT * from myUser");
BindData();
DataTable dt0 = this.GetDataFromGrid();
TextBox1.Text="administrator";
TextBox2.Text = "041612345";
DropDownList1.Items.Add("sdfsdfsdfsdf");
DropDownList2.Items.Add("系统管理人员");
if (!Page.IsPostBack)
{
DataTable dt0 = this.GetDataFromGrid();
{
}
}
} protected void Button3_Click(object sender, EventArgs e)
{
DataTable dt0 = this.GetDataFromGrid(); //button3 接收不到任何信息阿
//this.GetDataFromGrid(); 函数用于提取被checkbox 选取的行数据,这个函数放在哪里合适阿
}
protected void BindData()
{
DataSet myDataSet2 = myaccess_2.ReturnDataSet("SELECT * from myUser");
String user_id, user_name, user_password, user_depart, user_telephone, user_action;
DataTable table = new DataTable();
DataTable dt1 = new DataTable("Table1");
table = myDataSet2.Tables[0];
dt1.Columns.Add("编号");
dt1.Columns.Add("用户名称");
dt1.Columns.Add("用户密码");
dt1.Columns.Add("用户所属部门");
dt1.Columns.Add("联系方式");
dt1.Columns.Add("用户角色");
foreach (DataRow row in table.Rows)
{
// user_id = Convert.ToInt32(row["编号"].ToString());
user_id = (row["编号"].ToString());
user_name = row["User_Name"].ToString();
user_password = row["User_Password"].ToString();
user_depart = row["User_Depart"].ToString();
user_telephone = row["User_Telephone"].ToString();
user_action = row["User_Action"].ToString();
dt1.Rows.Add(new object[] { user_id, user_name, user_password,user_depart, user_telephone, user_action});
}
this.GridView1.DataSource = dt1;
this.GridView1.DataBind(); }
protected DataTable GetDataFromGrid()
{
DataTable dt1 = new DataTable("Table1"); dt1.Columns.Add("编号");//0
dt1.Columns.Add("用户名称");//1
dt1.Columns.Add("用户密码");//2
dt1.Columns.Add("用户所属部门");//3
dt1.Columns.Add("联系方式");//4
dt1.Columns.Add("用户角色");//5
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow gRow = GridView1.Rows[i];
if (((CheckBox)gRow.FindControl("CheckBox1")).Checked)
{
DataRow newRow = dt1.NewRow();
newRow[0] = GridView1.Rows[i].Cells[1].Text;
newRow[1] = GridView1.Rows[i].Cells[2].Text;
newRow[2] = GridView1.Rows[i].Cells[3].Text;
newRow[3] = GridView1.Rows[i].Cells[4].Text;
newRow[4] = GridView1.Rows[i].Cells[5].Text;
newRow[5] = GridView1.Rows[i].Cells[6].Text;
dt1.Rows.Add(newRow);
Response.Write("find");
}
}
dt1.AcceptChanges();
return dt1;
}
一\ 利用div层嵌套作了一个多页栏分割对话框,每个页栏内可以放置控件
二、GridView 嵌入checkbox 想选中checkbox后,将GridView 中的row 返回给 多页栏其他层的text控件中现在的问题是 GridView的checkbox选中检测函数,不知道放在那里 会被其他层text控件接收到阿,而且还发现一个现象
利用div嵌套的层 只要buttion按下 当前页的控件就消失了 怎么回事啊 非常急啊这是前台页面代码
<script type="text/javascript">
<!--
/*第一种形式 第二种形式 更换显示样式*/
function setTab(name, cursel, n) {
for (i = 1; i <= n; i++) {
var menu = document.getElementById(name + i);
var con = document.getElementById("con_" + name + "_" + i);
document.getElementById("Contentbox").style.height = "0px";
if (i == cursel && menu.className == "w") {
menu.className = "hover";
con.style.display = "block";
opendiv();
} else { menu.className = "w";
con.style.display = "none";
}
}
}
function opendiv() {
var height = document.getElementById("Contentbox").offsetHeight;
if (height < 400) {
document.getElementById("Contentbox").style.height = (height + 5) + "px";
setTimeout("opendiv()", 10);
}
}
//-->
</script> <div id="Tab1">
<div class="Menubox">
<ul>
<li id="one1" onmouseover="setTab('one',1,4)">查找用户</li>
<li id="one2" onmouseover="setTab('one',2,4)">新建用户</li>
<li id="one3" onmouseover="setTab('one',3,4)">修改用户</li>
<li id="one4" onmouseover="setTab('one',4,4)">删除用户</li>
<li></li>
<li></li>
<li></li>
<li></li>
<li>
</li>
</ul>
</div>
<div class="Contentbox" id="Contentbox">
<div id="con_one_1" style="display: none">
<div runat="server" >
查找用户
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound" AllowPaging="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="Button10" runat="server" Text="确定" onclick="Button10_Click" />
<asp:Button ID="Button11" runat="server" Text="取消" /> </div>
</div>
<div id="con_one_2" style="display: none">
<div>
新建用户 作为选项卡2<br/>
<asp:Label ID="Label6" runat="server" Text="用户名称 "></asp:Label>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><br/><br/>
<asp:Label ID="Label7" runat="server" Text="用户密码 "></asp:Label>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox><br /><br/>
<asp:Label ID="Label8" runat="server" Text="用户所属部门 "></asp:Label>
<asp:DropDownList ID="DropDownList3" runat="server"></asp:DropDownList><br /><br/>
<asp:Label ID="Label9" runat="server" Text="用户联系方式 "></asp:Label>
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox> <br /><br/>
<asp:Label ID="Label10" runat="server" Text="用户使用角色 "></asp:Label>
<asp:DropDownList ID="DropDownList4" runat="server"> </asp:DropDownList><br /><br/> <asp:Button ID="Button4" runat="server" Text="上一条记录" />
<asp:Button ID="Button5" runat="server" Text="下一条记录" />
<asp:Button ID="Button6" runat="server" Text="新建用户" /> </div>
</div>
<div id="con_one_3" style="display: none">
<div>
修改用户,作为选项卡3<br/>
<asp:Label ID="Label1" runat="server" Text="用户名称 "></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br/><br/>
<asp:Label ID="Label2" runat="server" Text="用户密码 "></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br /><br/>
<asp:Label ID="Label3" runat="server" Text="用户所属部门 "></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList><br /><br/>
<asp:Label ID="Label4" runat="server" Text="用户联系方式 "></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <br /><br/>
<asp:Label ID="Label5" runat="server" Text="用户使用角色 "></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server"> </asp:DropDownList><br /><br/> <asp:Button ID="Button1" runat="server" Text="上一条记录" />
<asp:Button ID="Button2" runat="server" Text="下一条记录" />
<asp:Button ID="Button3" runat="server" Text="修改用户" /> </div>
</div>
</div>
</div></asp:Content>后台页面代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyAccess;
using System.Data;
using System.Data.OleDb;
using System.Collections;
using System.Data.SqlClient;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
public MyAccess.MyAccess myaccess_2= new MyAccess.MyAccess();
public static int ss1;
protected void Page_Load(object sender, EventArgs e)
{
myaccess_2.ConnDbForAcccess(@" Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = h:\device1\device.mdb");
DataSet myDataSet2 = myaccess_2.ReturnDataSet("SELECT * from myUser");
BindData();
DataTable dt0 = this.GetDataFromGrid();
TextBox1.Text="administrator";
TextBox2.Text = "041612345";
DropDownList1.Items.Add("sdfsdfsdfsdf");
DropDownList2.Items.Add("系统管理人员");
if (!Page.IsPostBack)
{
DataTable dt0 = this.GetDataFromGrid();
{
}
}
} protected void Button3_Click(object sender, EventArgs e)
{
DataTable dt0 = this.GetDataFromGrid(); //button3 接收不到任何信息阿
//this.GetDataFromGrid(); 函数用于提取被checkbox 选取的行数据,这个函数放在哪里合适阿
}
protected void BindData()
{
DataSet myDataSet2 = myaccess_2.ReturnDataSet("SELECT * from myUser");
String user_id, user_name, user_password, user_depart, user_telephone, user_action;
DataTable table = new DataTable();
DataTable dt1 = new DataTable("Table1");
table = myDataSet2.Tables[0];
dt1.Columns.Add("编号");
dt1.Columns.Add("用户名称");
dt1.Columns.Add("用户密码");
dt1.Columns.Add("用户所属部门");
dt1.Columns.Add("联系方式");
dt1.Columns.Add("用户角色");
foreach (DataRow row in table.Rows)
{
// user_id = Convert.ToInt32(row["编号"].ToString());
user_id = (row["编号"].ToString());
user_name = row["User_Name"].ToString();
user_password = row["User_Password"].ToString();
user_depart = row["User_Depart"].ToString();
user_telephone = row["User_Telephone"].ToString();
user_action = row["User_Action"].ToString();
dt1.Rows.Add(new object[] { user_id, user_name, user_password,user_depart, user_telephone, user_action});
}
this.GridView1.DataSource = dt1;
this.GridView1.DataBind(); }
protected DataTable GetDataFromGrid()
{
DataTable dt1 = new DataTable("Table1"); dt1.Columns.Add("编号");//0
dt1.Columns.Add("用户名称");//1
dt1.Columns.Add("用户密码");//2
dt1.Columns.Add("用户所属部门");//3
dt1.Columns.Add("联系方式");//4
dt1.Columns.Add("用户角色");//5
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow gRow = GridView1.Rows[i];
if (((CheckBox)gRow.FindControl("CheckBox1")).Checked)
{
DataRow newRow = dt1.NewRow();
newRow[0] = GridView1.Rows[i].Cells[1].Text;
newRow[1] = GridView1.Rows[i].Cells[2].Text;
newRow[2] = GridView1.Rows[i].Cells[3].Text;
newRow[3] = GridView1.Rows[i].Cells[4].Text;
newRow[4] = GridView1.Rows[i].Cells[5].Text;
newRow[5] = GridView1.Rows[i].Cells[6].Text;
dt1.Rows.Add(newRow);
Response.Write("find");
}
}
dt1.AcceptChanges();
return dt1;
}
gridview事件是RowCommand事件 e.Command 和 e.Augument 单词可能打错了 自己仔细看属性就知道了。。