Single selection control for DataGrid under ASP.net
Source: Internet
Author: User
asp.net|datagrid| Control #region Declaration
//----------------------------------------------------------------------
//
Author: Li Miao (nick.lee)
//
Single selection control for DataGrid under ASP.net
Time: 2005-3-15
Boyorgril@msn.com
qq:16503096
Note: Please indicate the origin of the reference, thank you
//----------------------------------------------------------------------
#endregion
Namespace Message1
{
Using System;
Using System.Data;
Using System.Drawing;
Using System.Web;
Using System.Web.UI.WebControls;
Using System.Web.UI.HtmlControls;
Using System.Data.OleDb;
Using System.ComponentModel;
Using NickLee.Web.UI;
<summary>
Summary description of the WebUserControl1.
</summary>
public class WebUserControl1:System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.HtmlControls.HtmlInputHidden Rd;
protected System.Web.UI.WebControls.Label Label1;
public DataSet custDS = new DataSet ();
protected System.Web.UI.WebControls.Button Button1;
Code generated #region the Web forms Designer
Override protected void OnInit (EventArgs e)
{
//
CodeGen: This call is required for the ASP.net Web forms Designer.
//
InitializeComponent ();
Base. OnInit (e);
}
<summary>
Designer supports the desired method-do not use the Code Editor
Modify the contents of this method.
</summary>
private void InitializeComponent ()
{
This. Datagrid1.itemcommand + = new System.Web.UI.WebControls.DataGridCommandEventHandler (this. Datagrid1_itemcommand);
This. Datagrid1.itemdatabound + = new System.Web.UI.WebControls.DataGridItemEventHandler (this. Datagrid1_itemdatabound);
This. Datagrid1.selectedindexchanged + = new System.EventHandler (this. datagrid1_selectedindexchanged);
This. Button1.Click + = new System.EventHandler (this. Button1_Click);
This. Load + = new System.EventHandler (this. Page_Load);
}
#endregion
private void Datagrid1_itemdatabound (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
#region get the value of the primary key and check box for the current column
if (E.item.itemtype = = ListItemType.AlternatingItem | e.item.itemtype = = listitemtype.item)
{
public void SSSs ()
{
Place user code here to initialize page
String filenamestring = this. MapPath (".");
Filenamestring + = "\\chartdata.mdb";
String myconnectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" + filenamestring;
String Myselectquery=sql;
Open Data Base Connection
OleDbConnection myconnection = new OleDbConnection (myconnectionstring);
OleDbCommand mycommand = new OleDbCommand (mySelectQuery, MyConnection);
MyCommand.Connection.Open ();
Fill Data Set Object
OleDbDataAdapter CUSTDA = new OleDbDataAdapter ();
Custda.selectcommand = mycommand;
Custda.fill (custDS, "Default");
MyCommand.Connection.Close ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service