473,804 Members | 3,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

the data entered cant be viewed in the datagrid

16 New Member
unable to view data in datagrid
--------------------------------------------------------------------------------

the present problem is that i am unable to display data in datagrid....... but the data is visible in database..below is the code what should i do...earlier i could view it also below this code is the code which is in my html page plz help........


Expand|Select|Wrap|Line Numbers
  1. private void Page_Load(object sender, System.EventArgs e)
  2.         {
  3.             if (!Page.IsPostBack)
  4.             {
  5.                 BindData();
  6.             }
  7.  
  8.  
  9.             // Put user code to initialize the page here
  10.             OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" );
  11.             DataSet ds = new DataSet();
  12.             da.Fill(ds,"CMRS_BUSINESSAREA_MASTER");
  13.             DataGrid1.DataSource = ds.Tables["CMRS_BUSINESSAREA_MASTER"].DefaultView ;
  14.             DataGrid1.DataBind();
  15.  
  16.         }
  17.  
  18.  
  19.         public void BindData()
  20.         {
  21.             OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" ); 
  22.             DataSet ds = new DataSet(); 
  23.             da.Fill(ds);
  24.  
  25.             DataGrid1.DataSource = ds.Tables[0].DefaultView ;
  26.             DataGrid1.DataBind();
  27.  
  28.  
  29.         }
  30.         public void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs     e)
  31.         {
  32.             DataGrid1.EditItemIndex = e.Item.ItemIndex;
  33.             BindData(); 
  34.         }
  35.  
  36.         public void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs     e)
  37.         {
  38.             DataGrid1.EditItemIndex = -1; 
  39.             BindData(); 
  40.         }
  41.  
  42.         public void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs     e)
  43.         {
  44.             string str = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
  45.             OleDbConnection con1 = new OleDbConnection();
  46.             con1.ConnectionString = str;
  47.  
  48.  
  49.             TextBox txtAREADESCRIPTION =(TextBox) e.Item.Cells[1].Controls[0];
  50.             string strUpdateStmt;
  51.  
  52.             strUpdateStmt = "UPDATE CMRS_BUSINESSAREA_MASTER SET " + "CBM_BUSAREA_DESC = '" + txtAREADESCRIPTION.Text + "' " + "WHERE CBM_BUSAREA_CODE ='" + e.Item.Cells[0].Text +"'";
  53.  
  54.             cmd = new OleDbCommand(strUpdateStmt,con1);
  55.             con1.Open();
  56.             cmd.ExecuteNonQuery();         
  57.             DataGrid1.EditItemIndex = -1;
  58.             BindData();
  59.         }
  60.  
  61.  
  62.         #region Web Form Designer generated code
  63.         override protected void OnInit(EventArgs e)
  64.         {
  65.             //
  66.             // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  67.             //
  68.             InitializeComponent();
  69.             base.OnInit(e);
  70.         }
  71.  
  72.         /// <summary>
  73.         /// Required method for Designer support - do not modify
  74.         /// the contents of this method with the code editor.
  75.         /// </summary>
  76.         private void InitializeComponent()
  77.         {    
  78.             this.cmd = new System.Data.OleDb.OleDbCommand();
  79.             this.con1 = new System.Data.OleDb.OleDbConnection();
  80.             this.addbtn.Click += new System.EventHandler(this.addbtn_Click);
  81.             this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHand    ler(this.DataGrid1_CancelCommand);
  82.             this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHand    ler(this.DataGrid1_EditCommand);
  83.             this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHand    ler(this.DataGrid1_UpdateCommand);
  84.             this.Load += new System.EventHandler(this.Page_Load);
  85.  
  86.         }
  87.         #endregion
  88.  
  89.         private void addbtn_Click(object sender, System.EventArgs e)
  90.         {
  91.             string str = ConfigurationSettings.AppSettings["ConnectionString"].ToString();  
  92.  
  93.             OleDbConnection con1 = new OleDbConnection();
  94.             con1.ConnectionString = str;
  95.             OleDbCommand cmd = new OleDbCommand("Insert into cmrs_businessarea_master values('"+TextBox1.Text+"','"+TextBox2.Text+"')",con1);       
  96.             con1.Open();
  97.             cmd.ExecuteNonQuery();
  98.             con1.Close();
  99.             BindData();
  100.  
  101.  
  102.         }
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.     }
  110.  
  111.  
  112.  
  113. }


Expand|Select|Wrap|Line Numbers
  1. <asp:datagrid id="DataGrid1" style="Z-INDEX: 104; LEFT: 440px; POSITION: absolute; TOP: 304px"
  2.                 runat="server" Height="125px" Width="432px" OnUpdateCommand="DataGrid1_UpdateCommand" OnCancelCommand="DataGrid1_CancelCommand"
  3.                 OnEditCommand="DataGrid1_EditCommand" AutoGenerateColumns="False">
  4.                 <Columns>
  5.                     <asp:BoundColumn HeaderText="AREA CODE"></asp:BoundColumn>
  6.                     <asp:BoundColumn HeaderText="AREA DESCRIPTION"></asp:BoundColumn>
  7.                     <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
  8.                 </Columns>
  9.             </asp:datagrid></form>

-------------------------------------------------------------------------------------------------------
Thanks & Regards
Jul 27 '07 #1
1 1269
radcaesar
759 Recognized Expert Contributor
Its huge code and i can't play with it line by line. Debug ur code line by line and find where the bind fails.

Here is a sample

Dim conn As New OracleClient.Or acleConnection
' TODO: Modify the connection string and include any
' additional required properties for your database.
conn.Connection String = OracleConnectio n1.ConnectionSt ring '"Data Source=<oracle data source name>;Integrate d Security=yes"
Try
Dim mycommand As System.Data.Ora cleClient.Oracl eCommand
Dim myadapter As New System.Data.Ora cleClient.Oracl eDataAdapter

mycommand = New System.Data.Ora cleClient.Oracl eCommand
mycommand.Conne ction = conn
mycommand.Comma ndText = "select * from master_well_hea der where iuwi = '60804402080000 '"

myadapter = New System.Data.Ora cleClient.Oracl eDataAdapter
myadapter.Selec tCommand = mycommand

conn.Open()
myadapter.Fill( DataSet11)
DataGrid1.SetDa taBinding(DataS et11, "")

Catch ex As Exception
MessageBox.Show ("Failed to connect to data source", ex.Message)
Finally
conn.Close()
End Try
Jul 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1722
by: Antonio. kim | last post by:
Hello~ ^^ I have a question about getting excel data with oledbconnection. I entered '23190000' to Excel Cell and changed Column width to small, then the value chaged to 2E+07 or ####. And I saved this file...(maybe both data saved..viewed data and original data) when openning this file with oledbconnection, I got '2E+07' without original data '23190000'. I'd want to get original data '23190000' instead of viewed data like '2E+07',...
3
12668
by: Brian Smith | last post by:
I have a .aspx page (we'll call it Form1) with a datagrid on it. The datagrid is populated from a dataset that I manually entered data into (the data isn't in a database). The datagrid on Form1 also has a button column on it. I have another .aspx page (Form2) with an unpopulated datagrid on it. I want to populate it with all the columns from the row where the button was clicked on Form1. I know how to do what I want with the datagrid
2
1412
by: naija naija | last post by:
Hello guys i made a Datagrid with Editing,Update and Cancel using VS.NET. to my surprise nothing is on the screen after compilation .. By code below:- Imports System.Data Imports System.Data.SqlClient Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Public Class datagrid_edit Inherits System.Web.UI.Page
1
1818
by: pv_kannan | last post by:
One of our dev team members is having a strange problem with a datagrid... We are not seeing a datagrid's data getting refreshed after a new row is entered in a popup window inspite of resetting the datasource and rebinding it. We have a datagrid (enabled viewstate) that binds to a collection class that inherits the IList interface. The datagrid displays list of associated contacts for a customer order.
2
1104
by: Graham Blandford | last post by:
Hi all, Well I abandoned the use of a datagrid in my windows form and have opted to use a listbox instead. I have, following a helpful article created an item class and loaded it with values from an ADO recordset. Now, if I read the data I get a field (clientid) looking like this;
5
3116
by: Aspnot | last post by:
Background: I have a data entry form that is bound to a DataSet. This DataSet contains 9 tables and the form displays data from each table in textboxes, not a DataGrid. One of the tables in the ParentTable and the rest are children. For Example: The form shows the Customer and their most recently added Contact (in textboxes, not in a DataGrid). When I click the Add button on the form, I enumerate through all of the DataTables in the...
4
4210
by: jrett | last post by:
I'm new to ASP.NET and fairly inexperienced with web development in general, but I've been a professional software dev for over 10 years, C++, Unix and windows, C# the past 4 years. I've been working on a personal ASP.NET project, basically as a learning tool and I have a major issue which is really really getting on my nerves. I'm creating a web application in ASP.NET 2.0 which dynamically populates a table with text and text boxes....
1
1356
by: sherifffruitfly | last post by:
Hi all, I've got a form with a datagrid defined & presented to the user at runtime (code at the bottom.) With this, the user can happily enter all the data she likes. After a row of data is entered in the datagrid, and the datagrid is about to start a new row for the user, I'd like an UpdateDatabase(DataRow rowJustEntered) to be called. I suppose some kind of define-and-subscribe-to-some-event has to take place, but that's precisely...
1
2299
by: geeteshss | last post by:
Dear all, actually i spent a whole month on the R&D of datagrid edit ,update,cancel events but recently my guide told me to make it user friendly because no user would like to go on searching rows and columns in a datagrid if there are number of rows and columns.so in my web page i have got two labels two textboxes and three buttons namely add update and delete so when i click on the add button the data is added to datagrid and also displayed...
0
9706
marktang
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...
0
9143
agi2029
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...
1
7615
isladogs
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...
0
6851
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();...
0
5520
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...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.