Get Row Number in Datagrid

Hi 

I want to delete a databound row in a datagrid using the delete button on the datagrid. I have tried to use
Dim RowID As Integer = Convert.ToInt32(shOTQDataGrid1.Items.Item(CInt(e.Item.ItemIndex)))
to get the row number.
Dim SoqID As Label = CType(shOTQDataGrid1.Items(RowID).FindControl("SOQID"), Label)
I need to get the row number(e.g. 0). I search for the specific item "SOQID" and then use a custom Class to delete the record from the Database with the value of SoqID.Text.
Dim sh As New ShiftOvertimeQualifiersClass
Dim SoqID As Label = CType(shOTQDataGrid1.Items(RowID).FindControl("SOQID"), Label)
sh.Retrieve(Trim(SoqID.Text))
sh.Delete()

SOQID - DatagridItem
SoqID - Variable declared in VB to find the Datagrid Item.
I would appreciate any ideas or help.
Regards
Phillip
0
philliplg
1/19/2004 8:56:21 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

4 Replies
586 Views

Similar Articles

[PageSpeed] 40

This is a problem i've also had ...

This is what i did:
Add a colomn with the SOQID in ... just a databound column and set it invisible ...
Now whenever a delete button is clicked catch the postback in the itemcommand (or deletecommand) event ...
Then you can get the cell property from the datagrid (ie e.Item.Cells[0].text) and use that vakue to delete in the database ...
Verhoeven Bart

MCSD.NET

Technical Project Leader
0
Foefie
1/19/2004 12:45:04 PM
Thanks Foefie,

I found a way to get the row number. This is done on the Delete Click event in the datagrid.
Dim RowID As Integer = CInt(e.Item.ItemIndex)
Dim SoqID As Label = CType(shBreakDataGrid1.Items(RowID).FindControl("SOQD")_
, Label)
..
..
..
..
Regards
Phillip
0
philliplg
1/21/2004 8:51:37 AM
If you set your DataKeyField to your ID field

e.g. OrdersGrid.DataKeyField = "CustomerOrderID"
Then you can get that ID for the row selected in your delete command like this:
Dim orderID As String = OrdersGrid.DataKeys(e.Item.ItemIndex)

Simon
0
icSimon
1/21/2004 10:08:43 AM
Thanks icSimon for your reply!!
0
philliplg
1/22/2004 9:16:06 AM
Reply:

Similar Artilces:

How to set the row number and get the row number for ("selected row) in Datagrid
I face a problem that i can't get the selected row of the datagrid in both server side script (VB.net) and client side script (javascript) As i can't use the button column / hyperlink column in the datagrid. Thus , i need to handle the change the background color of the selected row and also to get the selected row number for Update/Delete. Thanks in advance. This depends on how do you perform the selection. Do you want to implement chaning of the SelectedRow at the client side without any postback? If you have no issues with postback, then you can do s little trick here: 1. ...

Getting the number of rows in a datagrid
Hi, The datagrid on my webform gets filled with some data from my database. I want to find the number of rows that are populated on the datagrid. What is the way to simply find the number of rows that have been filled with data. I want to use that in a for loop. Thanks, Snigdha After you populate your datagrid with data, all you have to do is:DataGrid.Items.CountThat will give you a count of how many rows are in your grid.DarmarkMark as Answer, if this reply answers your post. Get the row count based on your DataSource....For example, if the DaatSource is DataTable dtTable...it would ...

Getting row number when item is clicked on datagrid
I've got a datagrid on an asp.net page with a bound column and two template columns. The template columns contain image buttons that will allow users to edit and delete records corresponding to the value located in the bound column. The problem that I am having is finding out the row number that corresponds to the image button that is pressed. At the moment the image buttons has an OnClick event that runs some code but not sure how to pull in the datagrid row. Do I need to use the datagrid's itemcommand event somehow with the template column.  Cheers On cl...

Get the Row Number or Row ID
Hi, I am using Sybase Central v4.3 with Interactive SQL to query the SQL Commands. My concern is how to get the rownumber or row id in select queries. Is there any in built commands in the ASE. If not please suggest me how to get the rownumber. Thanks.... Unless i'm mistaken, ASE does not use a rowid... it can have a timestamp, but it is updated with every modification to the row. http://infocenter.sybase.com/help/topic/com.sybase.help.ase_15.0.blocks/html/blocks/blocks34.htm -- Cory Sane [TeamSybase] Certified Sybase Associate DBA for ASE 15.0 "Santhanam P" wrote...

how to set focus on a row of a dataGrid from outside the datagrid control.
after a user selects a choice in the dropdownlist, I am in the dropdownlist eventhandler OnSelected_event_handler() based on the choice how can i programmatically set the focus inside another control, ie datagrid control's row. note: the drop down list is OUTSIDE the datagrid, i.e not a template column private void ddl_SelectedIndexChanged(object sender, System.EventArgs e) { dg.SelectedIndex = ddl.SelectedValue; // is this right, i am trying to set focus to the row } What do you mean by "set the focus"? Are you looking to highl...

Composite Control not getting the design features for the DataGrid control
Hi, I made a composite control which consists of a datagrid and a button. But I am not able to get the design time appearance of the control. Meaning when I drag the control from the toolbox it does not appear as a datagrid. HighOnCodingWanna get high! If it is a true composite one e.g custom control which has DataGrid and Button as child controls, that's just normal because the control isn't a DataGrid. On such case, you should set all the propeties etc for it like it is with DataGrid (designers, editors and so on). If you'd want it still to behave like one without doing any extra...

How to get the row index of a selected row in listview control
Can someone please tell me how to get the index of a selected row in a listview.  <ItemTemplate> <asp:LinkButton runat="server" class="linkButton" id="xxxxx" Text='<%#Eval("documenttype") %>' CommandName="OpenFile" CommandArgument='<%#Eval("DocumentKey") %>'></asp:LinkButton></ItemTemplate>what you have to do is, in itemcommand event of ListView, you have to get the value of row indexif(e.CommandName == "corrospondingcommaandname"){     &nb...

How to place a DataGrid Control with in a DataGrid Control
Hi, I want to place a DataGrid control in a DataGrid control can any one plz tell me the procedure to place the control Thanks in Advance Krisamigo <!---<asp:DataGrid ID=dg_List runat=server><Columns><asp:TemplateColumn><ItemTemplate><asp:DataGrid ID=dg_List2 Runat=server></asp:DataGrid> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> ---> Hardik Joshi...

Getting Information from the Controls (TemplateField or BoundField ) from any of the Data Presentation Controls
Hello Everybody,I have a very important question for me.For example, I have a GridView.It has three BoundFields and one TemplateFieldI want to get information from any of the record (row,line etc ) using any of the BoundFields or TemplateFields.And also I want to accomplish this not only with GridView but also other Data Presentation Controls, DetailsView FormView and Repeater.Shortly, Can anybody help me how to refer Controls in GridView, FormView, DetailsView, RepeaterPS: I have searched in Google and many sites,forums. But I couldn't see any solution and see that many people ask the same ...

javascript: Get clientid of a control inside a datagrid or a user control
Get clientid of a control inside a datagrid or a user control in client side so you can use this id in document.getelementById( ) for some client side programming function GetClientId(strid) {      var count=document.forms[0].length;      var i=0;      var eleName;      for (.id;" pos="eleName.indexOf(strid);" if(pos="">i=0; i < count; i++ )      {        eleName=document.forms[0].elements.id;        pos=eleName.indexOf(strid)...

The row number and offset of each row in the page should have a matching entry in row number table
Is the proper correction for the following to recreate the table BCPout/IN or table to table insert, or just drop and recreate the index? Row number is 0. Is there a way to correct just the data page? Table Corrupt: The row number and offset of each row in the page should have a matching entry in row number table; check this page (page#=772121 row#=0 offset in row number table=0) Table Corrupt: The row number and offset of each row in the page should have a matching entry in row number table; check this page (page#=772121 row#=0 offset in row number table=0) Table Corrupt: The row...

how i can get all the information of specific row on clicking of any place of that row in datagrid
in my datagrid i have 4 columns. Among these one column is Type. Suppose this column has 3 different type like 1. question 2. section 3. option. so if i click any row of datagrid then i want to call different aspx page according to columnType.for example if type is question thenon clicking on it. i want to call Response.Redirect("question.aspx?id=" + _id.toString);i. e. i want to call different aspx according to type of that column and also i want to sent querystring id to that specific id belonging to first column of datagrid.ex:-'id'     'create date'    ...

how to make entire row of a datagrid clickable & get the full row in code?
Hi, is it possible to get a server-side event when the user clicks on a datagrid row? The user shouldn't be forced to click on a certain column entry; instead the event should be raised wherever on the row area the click happens without using the select of the datagrid    Thanks in advance,  Linu  Hi linukalex , Yes , you can do that. see this article to learn how to do this: http://www.aspxboy.com/private/5450/default.aspxSamu ZhangMicrosoft Online Community SupportPlease remember to click “Mark as Answer” on the post that helps you, and to click “Unmark...

getting the number of rows...
how can you get the number of rows in query resault with out filling dataset and checking the "count"? afaik - you can't - - you've got to have an entity to count the rows - the dataset is the 'finished product' that contains the result of your query - until you've queried and received the data from the database, you don't know how many rows you've receivedDavid WierMCP/ASPInsiderASPNet101.com - where to look first!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(Please 'Mark as ...

Web resources about - Get Row Number in Datagrid - asp.net.presentation-controls

Want to preview our new DataGrid for Xamarin.Forms?
tl;dr Zumero.DataGrid is a Xamarin.Forms control for displaying data in rows and columns. If you would be interested in testing and previewing ...

Mad King DataGrid
This post is about scrolling in WPF and the egocentric DataGrid control. I’ll give the project background but if all you’re interested in is ...

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 295 ...

Microsoft Silverlight - Wikipedia, the free encyclopedia
Microsoft Silverlight is an application framework for writing and running rich Internet applications , with features and purposes similar to ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Casaba Security » Products » X5s Testing Tool For Finding XSS Vulnerabilities
Security analysis, consulting, development and testing partners who understand your business strategy.

CodeGuru - Microsoft developers related ideas, articles, tips, tricks, comments, downloads, and so much ...
CodeGuru is where developers can come to share ideas, articles, questions, answers, tips, tricks, comments, downloads, and so much more related ...

Caliburn Micro: WPF, Silverlight, WP7 and WinRT/Metro made easy.
A small, yet powerful framework designed for WPF, Silverlight and WP7. It implements a variety of UI patterns for solving real-world problems. ...

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 11 Jul 2012

license-discuss@opensource.org: 11636: first draft of license proliferation committee report
FYI,the first draft report of the OSI's License Proliferation Committee.To join the OSI's license proliferation discuss email list, send anemail ...

Resources last updated: 12/5/2015 6:54:37 AM