Gridview貌似没有行单击事件吧?
如果我现在要单击Gridview中的某行,让页面跳转至指定的页面并且链接上面还带着此行的ID列的数据作为参数
请问各位,这个要怎么实现呢??
如果我现在要单击Gridview中的某行,让页面跳转至指定的页面并且链接上面还带着此行的ID列的数据作为参数
请问各位,这个要怎么实现呢??
解决方案 »
- TreeView如何复制节点及其所有子节点?
- gridview的Attributes如何输出没有转义的html?
- asp.net中excel导入导出问题
- css模式
- 页面跳转问题
- 初学者,问题,我登陆验证成功后,怎样用Server.Transfer("main/main.aspx"),让用户进入主窗口.
- 我用VS。NET2003打开aspnetforum原码 为何很多地方显示未知的控件??
- 下载的treeview控件问题?
- dropdownlist
- 用vs2010+easyui做前端,同事写wcf服务,再把两者连接
- 兼容,有谁写的cs和js能真正兼容,发现csdn的菜单都不兼容?
- Gridview控件, 能不能在没有数据源的时候也显示出来,
这就是数据的ID号,当参数传过去。url=xxx.aspx?ID=i,
Request.QueryString["ID"]获取ID
功能:1:添加行单击事件
2:获取行里面的单元格值主要代码:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
Button btnHiddenPostButton = e.Row.FindControl("btnHiddenPostButton") as Button;
if (btnHiddenPostButton != null)
{
e.Row.Attributes["onclick"] = String.Format("JavaScript:document.getElementById('{0}').click()", btnHiddenPostButton.ClientID);
// 额外样式定义
e.Row.Attributes["onmouseover"] = "Javascript:this.style.background='red'";
e.Row.Attributes["onmouseout"] = "javascript:this.style.background=''";
e.Row.Attributes["style"] = "cursor:pointer";
e.Row.Attributes["title"] = "单击选择当前行";
}
// 若希望将隐藏按钮单独放于一列,则设置此列隐藏,占位符 表示此列索引
//e.Row.Cells[].Attributes["style"] = "display:none";
}protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridViewRow row = null; Label lbl = null;
switch (e.CommandName)
{
case "HiddenPostButtonCommand": // 模板列
Control cmdControl = e.CommandSource as Control; // 表示触发事件的 IButtonControl,保持统一性并便于后续操作,我们这里直接转化为控件基类 Control
row = cmdControl.NamingContainer as GridViewRow; // 当前行
// 如何访问单元格值
// string txt = row.Cells[0].Text;
// 如何获取模板列中的 Label
lbl = row.FindControl("MyLabelID") as Label;
// 执行更多的自定义操作
string txt = lbl.Text.ToString();
Response.Write(txt);
Response.Write(String.Format("GridView Version 当前第 {0} 行:", row.RowIndex + 1));
break;
// case "Command2":
// more cases
}
}
这个没试过额!嘎嘎
protected void Grd_Customer_SelectedIndexChanged(object sender, EventArgs e)
{
string Id = this.Grd_Customer.SelectedItem.Cells[0].Text;//id
Session["Id"] = Id;
Session["TrueName"] = this.Grd_Customer.SelectedItem.Cells[4].Text;//人员姓名
Session["Mobile"]=this.Grd_Customer.SelectedItem.Cells[5].Text;//手机号
Session["content"] = this.Grd_Customer.SelectedItem.Cells[7].Text;//短信内容;
Session["LoginName"]=this.Grd_Customer.SelectedItem .Cells[8].Text ;//登录名;
}
双击 ondbclick事件
{
id = gv.DataKeys[i].Value.ToString(); gv.Rows[i].Attributes["style"] = "Cursor:hand";
gv.Rows[i].Attributes.Add("ondblclick", "javascript:tb_show('New Page', test.aspx?id=" + id + ");");
}