473,387 Members | 1,463 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,387 software developers and data experts.

Having a problem with my datagrid

47
I select the delete button and it takes me to the event but I can't get the information about the row I'm deleting. It says the selected row is -1 when it's actually the third row. I have to pass the information to a structure befor the record can be deleted. How do I get this information?
Jan 23 '09 #1
6 978
Frinavale
9,735 Expert Mod 8TB
Could you please post the code that you have so far so that we can see what you're doing?

Thanks,

-Frinny
Jan 23 '09 #2
kimbred
47
Don't really have much. My intentions are to take several values in the gridrow and pass them to a class that properly deletes the record. Below is all I have for the row deleted event.
Expand|Select|Wrap|Line Numbers
  1.     protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
  2.     {
  3.  
  4.         BLL_SelfService.DelPhnRec(Profile.Employees.EmpId,Convert.ToInt16(GridView1.SelectedRow.Cells[0]),Convert.ToInt16(GridView1.SelectedRow.Cells[1]),Convert.ToString(GridView1.SelectedRow.Cells[2]));
  5.     }
Jan 23 '09 #3
Frinavale
9,735 Expert Mod 8TB
Try implementing a method that handles the RowDeleting Event instead of the RowDeleted Event ;)

-Frinny
Jan 23 '09 #4
kimbred
47
This tells me that the selected row is NULL
Jan 23 '09 #5
Frinavale
9,735 Expert Mod 8TB
You shouldn't be trying to get the Selected Row..

You retrieve the row that the user wants to delete by getting the RowIndex from the "e" parameter (from the GridViewDeleteEventArgs passed into the method).
Expand|Select|Wrap|Line Numbers
  1.  Private Sub myGridView_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles myGridView.RowDeleting
  2.         Dim row = GV_Groups.Rows(e.RowIndex)
  3. End Sub
Expand|Select|Wrap|Line Numbers
  1. void myGridView_RowDeleting(Object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e ) 
  2. {
  3.        GridViewRow row = GV_Groups.Rows[e.RowIndex];
  4. }
Jan 26 '09 #6
kimbred
47
Thanks for your help.
Jan 26 '09 #7

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

Similar topics

0
by: Emerson | last post by:
The following assumes a System.Windows.Forms.DataGrid with a System.Data.DataTable set as the DataSource. I'm programming in C# Here's my scenario I click in a cell on a DataGrid. I enter some...
4
by: Gidi | last post by:
Hello i'm writing a C# Window appliction and i'm using DataGrid as a table i want the user to enter data in each column and by pressing the enter key to move to the next column how can i write it...
5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
0
by: web1110 | last post by:
Hi y'all, I have written a ComboBox derived from DataGridTextBoxColumn to use in a DataGrid. It seems to be working ok, however... When the ComboBox is displayed, the mouse scroll wheel...
1
by: Manish | last post by:
Hello Everyone I am having weird problem in my datagrid bounded to datatable. My datatable is populated from SQLServer database. DataGrid has Calculated column Week% and Calculated record, SPLH....
0
by: samir | last post by:
hi i have a datagrid where i display some columns. i want to have some columns from the db and 2 i calculate,i can display it but problem is how to sort the calculated columns. here is what i am...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
0
by: Iain | last post by:
Hi All I have a datagrid which takes it's data from a table on a remote i-series. This datagrid is loaded on Page Load and the user is able to select a record to edit by pressing the...
0
by: RazSam | last post by:
Hi I am developing in c# .net 2,0 web forms and having some problems. Code is attached below. I have written code to export the contents of a Grid View to Excel, this works. The problem occurs...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.