GridView行选择事件,单击GridView中某一行任意位置提出这条记录
来源:互联网 发布:java开发工程师笔试题 编辑:程序博客网 时间:2024/05/16 10:14
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;
using System.Data.SqlClient;
public partial class DataViewSelectRow : System.Web.UI.Page
...{
protected void Page_Load(object sender, EventArgs e)
...{
if (!IsPostBack)
...{
lblStr.Text = "select * from Products";
DataSet ds = BindSqlServer(lblStr.Text); //
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
private DataSet BindSqlServer(string str)
...{
SqlConnection Conn = new SqlConnection("server=.;uid =sa ; pwd=;database = northwind");
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(str, Conn);
da.Fill(ds);
return ds;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
...{
GridView1.PageIndex = e.NewPageIndex;
DataSet ds = BindSqlServer("select * from Products");
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
...{
//注册行单击事件
e.Row.Attributes.Add("onclick", "javascirpt:__doPostBack('GridView1','Select$" + e.Row.RowIndex + "')");
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
...{
Response.Write(GridView1.SelectedValue); //显示单示列的ID
//得到ID后将其付给一个变量
lblStr.Text = "select * from products where Productid =" + GridView1.SelectedValue;
DataSet ds = new DataSet();
ds = BindSqlServer(lblStr.Text);
this.TextBox1.Text = ds.Tables[0].Rows[0]["QuantityPerUnit"].ToString();
}
}
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;
using System.Data.SqlClient;
public partial class DataViewSelectRow : System.Web.UI.Page
...{
protected void Page_Load(object sender, EventArgs e)
...{
if (!IsPostBack)
...{
lblStr.Text = "select * from Products";
DataSet ds = BindSqlServer(lblStr.Text); //
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
private DataSet BindSqlServer(string str)
...{
SqlConnection Conn = new SqlConnection("server=.;uid =sa ; pwd=;database = northwind");
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(str, Conn);
da.Fill(ds);
return ds;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
...{
GridView1.PageIndex = e.NewPageIndex;
DataSet ds = BindSqlServer("select * from Products");
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
...{
//注册行单击事件
e.Row.Attributes.Add("onclick", "javascirpt:__doPostBack('GridView1','Select$" + e.Row.RowIndex + "')");
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
...{
Response.Write(GridView1.SelectedValue); //显示单示列的ID
//得到ID后将其付给一个变量
lblStr.Text = "select * from products where Productid =" + GridView1.SelectedValue;
DataSet ds = new DataSet();
ds = BindSqlServer(lblStr.Text);
this.TextBox1.Text = ds.Tables[0].Rows[0]["QuantityPerUnit"].ToString();
}
}
- GridView行选择事件,单击GridView中某一行任意位置提出这条记录
- GridView行选择事件,单击GridView中某一行任意位置提出这条记录
- GridView行选择事件,单击GridView中某一行任意位置提出这条记录
- GridView行选择事件,单击GridView中某一行任意位置提出这条记录
- GridView行单击事件
- 如何在gridview中单击“选择”时,取出这条记录的值
- GridView单击行 选择checkbox
- gridview 点击某行任意位置选择该行
- GridView行选择事件
- 扩展GridView实现多选(全选)、点击行任意位置选择行、选中变色、添加双击事件等
- 扩展GridView实现多选(全选)、点击行任意位置选择行、选中变色、添加双击事件等
- 扩展GridView实现多选(全选)、点击行任意位置选择行、选中变色、添加双击事件等
- 给GridView添加行单击事件
- 求助 gridview 的 行单击事件
- 求助 gridview 的 行单击事件
- 求助 gridview 的 行单击事件
- 求助 gridview 的 行单击事件
- GridView行的单击/双击事件
- 文泉驿正黑体可下载使用了!
- 开张
- DWR帮助文档-dwr.xml文件的配置
- 网友支招:五大秘籍助刘翔奥运会上提速(组图)
- 路边小记
- GridView行选择事件,单击GridView中某一行任意位置提出这条记录
- 缓存-反向代理-负载均衡@Plone+squid(黑色技术)
- PostgreSQL在Linux上的恢复
- css脚本详解
- 关于AD的操作
- 打开Solaris的串口输出
- DWR帮助说明-服务器端程序的编写
- php header()函数使用说明
- 面向对象分析与设计OOAD