473,320 Members | 2,147 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.

grid view problem

Dear All,

I have one problem in gridview.Im using C# code and ADO connection.
In the grid view ,data is not updated in the update link....Please hep me to solve this issue.........
Im use grid_Row Editing Event to edit the grid.......which command should use to update the data........and send me sample update code in ADO connection
Jan 25 '08 #1
3 1090
kenobewan
4,871 Expert 4TB
Welcome to TSDN. Heres an article that may help:
GridView..::.RowEditing Event
Jan 25 '08 #2
mathewgk80
103 100+
Hi,
The sample code is given below.....

Expand|Select|Wrap|Line Numbers
  1.  protected void gdvPurchase_RowUpdating(object sender, GridViewUpdateEventArgs e)
  2.     {
  3.  
  4.         try
  5.         {
  6.             GridViewRow row = gdvPurchase.Rows[e.RowIndex];
  7.             string strPurchaseId = txtPurchaseId.Text;
  8.             string strProductNameNew = ((TextBox)row.Cells[0].Controls[1]).Text;
  9.             string strNoOfItems = ((TextBox)row.Cells[1].Controls[1]).Text;
  10.             int intNoOfItems = int.Parse(strNoOfItems);
  11.             string strPricePerUnit = ((TextBox)row.Cells[2].Controls[1]).Text;
  12.             int intPricePerUnit = int.Parse(strPricePerUnit);
  13.             sqlConRowUpdate = new SqlConnection(strConnectionString);
  14.             sqlConRowUpdate.Open();
  15.             SqlCommand SqlCmdRowUpdate = new SqlCommand();
  16.             SqlCmdRowUpdate.Connection = sqlConRowUpdate;
  17.             SqlCmdRowUpdate.CommandText = "procUpdatePDetails";
  18.             SqlCmdRowUpdate.CommandType = CommandType.StoredProcedure;
  19.             SqlCmdRowUpdate.Parameters.Add("@purchaseid", SqlDbType.VarChar).Value = strPurchaseId;
  20.             SqlCmdRowUpdate.Parameters.Add("@productname", SqlDbType.VarChar).Value = strProductNameNew;
  21.             SqlCmdRowUpdate.Parameters.Add("@noofitems", SqlDbType.Int).Value = intNoOfItems;
  22.             SqlCmdRowUpdate.Parameters.Add("@priceperunit", SqlDbType.Int).Value = intPricePerUnit;
  23.             SqlCmdRowUpdate.ExecuteNonQuery();
  24.             gdvPurchase.EditIndex = -1;
  25.             gdvPurchase.DataSource = objBusinessLogic.fnSelectPurchaseDetails(txtPurchaseId.Text);
  26.             gdvPurchase.DataBind();
  27.         }
  28.         catch (Exception excRowUpdating)
  29.         {
  30.             Response.Write(excRowUpdating.Message.ToString());
  31.  
  32.         }
  33.         finally
  34.         {
  35.             sqlConRowUpdate.Close();
  36.         }
  37.  
  38.  
  39.     }

Regards,

Mathew
Jan 25 '08 #3
Dear Sir,

im not using any texbox in my gridview.i want to just update the data into the database.....pls send me the sample code....
Jan 28 '08 #4

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

Similar topics

12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
5
by: sdbranum | last post by:
I have been using Visual C#.NET to code a large project having many data adapters, data sets, datagrids, multiple forms with tab pages, each containing various controls (mostly label, text boxes,...
10
by: John Wilson | last post by:
My app produces some long datatables to display in a grid. So I put them in a div so users can scroll. But the grid headers scroll out of view. I would like to stop them doing this. Can I fix them...
3
by: Dave | last post by:
I am designing a web page using VS2003 ASP.NET. The page contains various DIVs (panels), one of which is in grid layout. The controls in this DIV render correctly in IE, but when using Firefox they...
1
by: Ed | last post by:
hi everyone, maybe someone can give me a hand here. I am working with vb 2005 and i have a gridview that i am loading data from a recordset. I have the recordset returned from the query and i am...
1
by: puja | last post by:
hi all, am using grid view in asp.net 2.0 . My problem is easy but can't get it to work. My grid view id = grdContract and am binding grid view using dataset My dataset returns 5 columns from...
2
by: Umeshnath | last post by:
Hi, I have placed a grid view inside Atlas panel. On click of a button event, data is populated in the grid view, I want to add scroll bar instead of increasing the size of grid view. I have...
0
by: zafar | last post by:
I don't know what property should be used for hiding colums in Data Grid, whereas in Data Grid View we have DataGridView1.Colums(index).Visible = False , But how can I hide Colums in Data Grid.....
1
by: =?Utf-8?B?TG95b2xhIHN0YWxpbg==?= | last post by:
Hi, I am using ASP.Net 2.0 version and Windows'XP OS. I am useing the Grid view control to display the user details along with the paging concept provided by the grid view control. When i...
2
by: shahidrasul | last post by:
hi in my project a data grid view in which is show a list of employees which i get from database, i add a even double click on any cell , when i click on any cell, i want to display a form to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
1
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: 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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: 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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.