473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to update data in datagrid by an update button outside the datagrid

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 .....now i need the datagrid to function in such a manner that when i select a row it is selected in the datagrid(which has got only two columns of which one doesnt need to be updated as it being the primary key) and the data is automatically displayed in the textboxes and i can update it there and then when i click the update button it is updated in the datagrid........anybody please provide the code being a beginner i cant figure it out how to do it.....also if someone can provide the code to put a checkbox to select a particular row in datagrid and a search button to search anything in the datagrid it will be whole lot of help .........

i am pasting the present code
here my table name is CMRS_BUSINESSAREA_MASTER the column names are CBM_BUSAREA_CODE(which doesnt need to be updated) and CBM_BUSAREA_DESC
the datatype i am using is varchar2
the .net framework is 1.1 and visual studio.net 2003
Expand|Select|Wrap|Line Numbers
  1. private void Page_Load(object sender, System.EventArgs e)
  2.         {
  3.  
  4.             if (!Page.IsPostBack)
  5.             {
  6.                 BindData();
  7.             }        
  8.             OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" );
  9.             DataSet ds = new DataSet();
  10.             da.Fill(ds,"CMRS_BUSINESSAREA_MASTER");
  11.             DataGrid1.DataSource = ds.Tables["CMRS_BUSINESSAREA_MASTER"].DefaultView ;
  12.             DataGrid1.DataBind();
  13.         }
  14.  
  15.  
  16.         public void BindData()
  17.         {
  18.             OleDbDataAdapter da = new OleDbDataAdapter("SELECT *FROM CMRS_BUSINESSAREA_MASTER","Provider=MSDAORA.1;User ID=meter_reading;Password=colony;Data Source=windev;OLEDB.NET=true;" ); 
  19.             DataSet ds = new DataSet(); 
  20.             da.Fill(ds);
  21.  
  22.             DataGrid1.DataSource = ds.Tables[0].DefaultView ;
  23.             DataGrid1.DataBind();
  24.  
  25.  
  26.         }
  27. private void addbtn_Click(object sender, System.EventArgs e)
  28.         {
  29.             string str = ConfigurationSettings.AppSettings["ConnectionString"].ToString();  
  30.  
  31.             OleDbConnection con1 = new OleDbConnection();
  32.             con1.ConnectionString = str;
  33.             OleDbCommand cmd = new OleDbCommand("Insert into cmrs_businessarea_master values('"+TextBox1.Text+"','"+TextBox2.Text+"')",con1);         
  34.             con1.Open();
  35.             cmd.ExecuteNonQuery();
  36.             con1.Close();
  37.             BindData();
  38.  
  39.  
  40.         }
  41. private void updtbtn_Click(object sender, System.EventArgs e)
  42.         {
  43.  
  44.         }
  45.  
  46.         private void delbtn_Click(object sender, System.EventArgs e)
  47.         {
  48.  
  49.         }
Thanks In advance and regards
geetesh
Aug 6 '07 #1
1 2268
radcaesar
759 Expert 512MB
Since u have got the values in TextBox, Store the RowIndex when click and update that using that PrimaryKey Value.
Aug 6 '07 #2

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

Similar topics

0
by: irene | last post by:
Hi,I am trying to update a datagrid of a web page but I am having the problems. I am using the sqldataadapter and dataset to bind it to a datagrid. The web page shows a list of people(the datagrid...
2
by: Manish | last post by:
Hey folks I am having a weird problem in ASP .Net. My page is in C#. I have a datagrid, which populates based on selection in drop down box on ASP page. This datagrid has template textbox colum in...
3
by: pmud | last post by:
Hi, I have an ASP.NET application using C# code. I am using a datagrid to display records from a database based on a user input, i.e a user enters a compnay name in text box & when he clicks a...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
6
by: Frank | last post by:
Hopefully this is the correct group for this message. My previous post to (I assume) a non-.net group was not welcomed. I have a form with 7 text boxes that are all bound to fields of a...
5
by: Stephen Plotnick | last post by:
I'm very new to VB.NET 2003 Here is what I have accomplished: MainSelectForm - Selects an item In a public class I pass a DataViewRow to ItemInformation1 Form ItemInformation2 Form
0
by: Erik | last post by:
Why isn't my update method getting called? Pasted below is an aspx from a 1.1 application I'm working on. It has two textboxes and a button for inserting data into the database, and a datagrid...
0
by: Patty05 | last post by:
I have a datagrid on a form that update properly when form loads. When the program runs and I type in/add a new row in the datagrid, it does not save the changes. Any help would be greatly...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.