First i would like to thank those persons who helped me out in solving my earlier problems
the present problem is that i am unable to display data in datagrid....... but the data is visible in database..below is the code - private void Page_Load(object sender, System.EventArgs e)
-
{
-
if (!Page.IsPostBack)
-
{
-
BindData();
-
}
-
-
-
// Put user code to initialize the page here
-
OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" );
-
DataSet ds = new DataSet();
-
da.Fill(ds,"CMRS_BUSINESSAREA_MASTER");
-
DataGrid1.DataSource = ds.Tables["CMRS_BUSINESSAREA_MASTER"].DefaultView ;
-
DataGrid1.DataBind();
-
-
}
-
-
-
public void BindData()
-
{
-
OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" );
-
DataSet ds = new DataSet();
-
da.Fill(ds);
-
-
DataGrid1.DataSource = ds.Tables[0].DefaultView ;
-
DataGrid1.DataBind();
-
-
-
}
-
public void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
-
{
-
DataGrid1.EditItemIndex = e.Item.ItemIndex;
-
BindData();
-
}
-
-
public void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
-
{
-
DataGrid1.EditItemIndex = -1;
-
BindData();
-
}
-
-
public void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
-
{
-
string str = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
-
OleDbConnection con1 = new OleDbConnection();
-
con1.ConnectionString = str;
-
-
-
TextBox txtAREADESCRIPTION =(TextBox) e.Item.Cells[1].Controls[0];
-
string strUpdateStmt;
-
-
strUpdateStmt = "UPDATE CMRS_BUSINESSAREA_MASTER SET " + "CBM_BUSAREA_DESC = '" + txtAREADESCRIPTION.Text + "' " + "WHERE CBM_BUSAREA_CODE ='" + e.Item.Cells[0].Text +"'";
-
-
cmd = new OleDbCommand(strUpdateStmt,con1);
-
con1.Open();
-
cmd.ExecuteNonQuery();
-
DataGrid1.EditItemIndex = -1;
-
BindData();
-
}
-
-
-
#region Web Form Designer generated code
-
override protected void OnInit(EventArgs e)
-
{
-
//
-
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
-
//
-
InitializeComponent();
-
base.OnInit(e);
-
}
-
-
/// <summary>
-
/// Required method for Designer support - do not modify
-
/// the contents of this method with the code editor.
-
/// </summary>
-
private void InitializeComponent()
-
{
-
this.cmd = new System.Data.OleDb.OleDbCommand();
-
this.con1 = new System.Data.OleDb.OleDbConnection();
-
this.addbtn.Click += new System.EventHandler(this.addbtn_Click);
-
this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand);
-
this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
-
this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
-
this.Load += new System.EventHandler(this.Page_Load);
-
-
}
-
#endregion
-
-
private void addbtn_Click(object sender, System.EventArgs e)
-
{
-
string str = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
-
-
OleDbConnection con1 = new OleDbConnection();
-
con1.ConnectionString = str;
-
OleDbCommand cmd = new OleDbCommand("Insert into cmrs_businessarea_master values('"+TextBox1.Text+"','"+TextBox2.Text+"')",con1);
-
con1.Open();
-
cmd.ExecuteNonQuery();
-
con1.Close();
-
BindData();
-
-
-
}
-
-
-
-
-
-
-
}
-
-
-
-
}
1 1432
First i would like to thank those persons who helped me out in solving my earlier problems
the present problem is that i am unable to display data in datagrid....... but the data is visible in database..below is the code - private void Page_Load(object sender, System.EventArgs e)
-
{
-
if (!Page.IsPostBack)
-
{
-
BindData();
-
}
-
-
-
// Put user code to initialize the page here
-
OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" );
-
DataSet ds = new DataSet();
-
da.Fill(ds,"CMRS_BUSINESSAREA_MASTER");
-
DataGrid1.DataSource = ds.Tables["CMRS_BUSINESSAREA_MASTER"].DefaultView ;
-
DataGrid1.DataBind();
-
-
}
-
-
-
public void BindData()
-
{
-
OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" );
-
DataSet ds = new DataSet();
-
da.Fill(ds);
-
-
DataGrid1.DataSource = ds.Tables[0].DefaultView ;
-
DataGrid1.DataBind();
-
-
-
}
-
public void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
-
{
-
DataGrid1.EditItemIndex = e.Item.ItemIndex;
-
BindData();
-
}
-
-
public void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
-
{
-
DataGrid1.EditItemIndex = -1;
-
BindData();
-
}
-
-
public void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
-
{
-
string str = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
-
OleDbConnection con1 = new OleDbConnection();
-
con1.ConnectionString = str;
-
-
-
TextBox txtAREADESCRIPTION =(TextBox) e.Item.Cells[1].Controls[0];
-
string strUpdateStmt;
-
-
strUpdateStmt = "UPDATE CMRS_BUSINESSAREA_MASTER SET " + "CBM_BUSAREA_DESC = '" + txtAREADESCRIPTION.Text + "' " + "WHERE CBM_BUSAREA_CODE ='" + e.Item.Cells[0].Text +"'";
-
-
cmd = new OleDbCommand(strUpdateStmt,con1);
-
con1.Open();
-
cmd.ExecuteNonQuery();
-
DataGrid1.EditItemIndex = -1;
-
BindData();
-
}
-
-
-
#region Web Form Designer generated code
-
override protected void OnInit(EventArgs e)
-
{
-
//
-
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
-
//
-
InitializeComponent();
-
base.OnInit(e);
-
}
-
-
/// <summary>
-
/// Required method for Designer support - do not modify
-
/// the contents of this method with the code editor.
-
/// </summary>
-
private void InitializeComponent()
-
{
-
this.cmd = new System.Data.OleDb.OleDbCommand();
-
this.con1 = new System.Data.OleDb.OleDbConnection();
-
this.addbtn.Click += new System.EventHandler(this.addbtn_Click);
-
this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand);
-
this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
-
this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
-
this.Load += new System.EventHandler(this.Page_Load);
-
-
}
-
#endregion
-
-
private void addbtn_Click(object sender, System.EventArgs e)
-
{
-
string str = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
-
-
OleDbConnection con1 = new OleDbConnection();
-
con1.ConnectionString = str;
-
OleDbCommand cmd = new OleDbCommand("Insert into cmrs_businessarea_master values('"+TextBox1.Text+"','"+TextBox2.Text+"')",con1);
-
con1.Open();
-
cmd.ExecuteNonQuery();
-
con1.Close();
-
BindData();
-
}
-
}
-
}
I didnt understand your logic......why the code between line 9 and 14 in Page_Load event...you are calling BinData() first time when page loads...thats fine...then why are you again binding the grid.......outs ide if block in Page_Load....
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Chumley the Walrus |
last post by:
IN my code behind .vb page for a delete records script (this also does
a deletion confirmation with a javascript popup, this gets called on
my front .aspx page with the datagrid), I'm not sure if he
row.delete() in my Delete_Row sub is correct because when deleting a
record from the dbase, it doesnot get deleted from the actual
database, even tho on the datagrid it does show that the record is
deleted:
'''''''''''''
|
by: Alpha |
last post by:
Hi,
I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a
listbox that I have binded to a dataset table, "source" which has 3 columns.
I would like to display 2 of those columns, "scode" and "sname", as 1 column
(if not possible then 2 columns will be fine) in the listbox. Can the
listbox display 2 columns information from the dataset and how can I do that?
Also, I set the property of the listbox to selectionmode...
|
by: Andrew S. Giles |
last post by:
Hello,
I am importing a flat text file, and putting it into a datagrid for display
on a form.
Currently the users have their dates and times seperated. I have two
fields, therefore in the datatable feeding the datagrid control. Both are of
the DateTime Type. How do I get the time field to display only the Time, and
not the date, which is apparently the default.
|
by: Craig Banks |
last post by:
If a row of data in a dataset has a lot of columns the row displaying the
data in a datagrid will run way off the screen. What I'd like to do is
display a row of data over several datagrid rows so the user doesn't have to
scroll horizontally. Essentially, I want to wrap a datagrid row (not text in
individual columns) with as much control as possible. Make sense?
While this seems simple enough on the surface, I can't figure out how to do...
|
by: CVerma |
last post by:
Hi,
I have an embedded datagrid within a datalist. I am not able to
perfrom paging in the datagrid. Any ideas? Here is my code:
Here is my Simplegrid.cs file:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
| |
by: harry |
last post by:
Hi all,
I have a datagrid (language C#) populated using a stored procedure. I
want one of the column to display complete name instead of
abbreviation. Can I change the display dynamically in the datagrid or
should I change it in stored procedure?
|
by: tshad |
last post by:
I have a Windows form where I am trying to set the BackColor of a control
and check the color before I do it:
If control.BackColor = System.Drawing.Color.Blue Then
ChangeColor(control, Color.Red)
Else
ChangeColor(control, Color.Blue)
End If
But I get an error:
|
by: pozze |
last post by:
Hi,
I need to display images and other record information retrieved from an SQL 2005 database in a datagrid on a web page. I'm coding in VB .net I have recently changed over from VB ASP and i'm still getting used to .net
I can successfully upload images and other data into the SQL Database, I'm currently storing RecordID, File Name, Type of File (mime), File Size, and File Data.
I can retreive non binary data to a datagrid but I cannot...
|
by: simonyong |
last post by:
hello, anyone..
im newbie to asp.net
my problem is :
My task is related to view all data from a table called "employee "
i had create a datagrid where called data from database and successfully display in a datagrid..
each employee will hav their own personnel_number and direct_manager_personnel_number which refer to who is his/her direct boss...
eg.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |