Help! Find row on which a button was pressed in the gridview control in .NET 2.0

How do you get the exact row (and column data from that row)  on which a button was pressed within a gridview.

In .NET v1 using the datagrid control the following
construction was available:
objArgs.Item.Cells(n).Text
using the datagrid DataGridCommandEventArgs parameter.

choices in gridview are

    Sub cmdBackTestSummary(ByVal objSender As Object, ByVal objArgs As GridViewCommandEventArgs)
 ' objArgs.commandname
 ' objargs.commandarguement
 ' objargs.commandsource
    End Sub

but no objArgs.Item.Cells(n)

So how do you get the exact row (and column data from that row)  on which a button was pressed within a gridview?

0
Socrates470BC
2/24/2006 7:16:15 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
883 Views

Similar Articles

[PageSpeed] 55

Something similar to the following (in C# since I'm less familiar with VB):

if (e.CommandName == "some-command-name")

{

GridView gv = e.CommandSource as GridView;

int ind = Int32.Parse(e.CommandArgument.ToString());

// something similar to following... you may also use FindControl() if using template columns with ID assigned to controls

Button btn = gv.Rows[ind].Cells[3].Controls[0] as Button;

string text = btn.Text;

}

 

0
jcasp
2/24/2006 7:53:35 PM

Values returned as follows:

objArgs.CommandName = cmdFeb
objArgs.CommandArgument.tostring =
objArgs.CommandSource = System.Web.UI.WebControls.Button

I can get the column as the command name tells me which column, I expected to get some info from the command argument, but this appears to be empty.

0
Socrates470BC
2/24/2006 8:20:03 PM
Reply:

Similar Artilces:

Master Details in two seperate GridView Controls
I am simply trying to have a list of people in the top grid control (works fine), then when selected have the second Grid Control show details for that person(not working). Here is what I am trying from the load event: Sub BindData() Dim myConnection As New MySql.Data.MySqlClient.MySqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionSql")) Dim strPersonSQL, strActSQL As String strPersonSQL = "select row_id, first_name, last_name, middle_initial, dsi_id, created, created_by, program_of_study, email from tbl_person" Dim myPerCommand As New MySqlClient.MySqlComm...

Datagrid(.net 1.1) to GridView(.net 2.0) and using the RowUpdating event how to extract the values from the controls.
Ok  This is the settings: I use a Viewgrid with only itemtemplate colums for example. <asp:TemplateField HeaderText="Test"><ItemTemplate><asp:Label id="LBL_Test" text='<%# DataBinder.Eval(Container.DataItem, "Test1") %>' runat="server" meta:resourcekey="LBL_TestResource1"></asp:Label></font></ItemTemplate> <EditItemTemplate><asp:TextBox ID="HDN_Test" Text='<%# DataBinder.Eval(Container.DataItem, "Test1") %>' Runat="server" meta:resourcekey="HDN_TestResource1" /></EditItemTemplate></asp:TemplateField>  The ...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

How to validate controls on a .NET 2.0 Web user Control
Hi Guys, (ASP.NET 2.0 / C#) I've looked thorugh every post on validating web user controls (and know about Pter Blum's Professional Validation and More package) - but can't seem to get my head around whre to start. I have a web user control, called wucICL.ascx on a we page called AddEditInvestment.aspx.  I would like to validate a couple of DropDownLists (ddlAccounts and ddlContacts) when the Insert and Update buttons are clicked on the AddEdit Investment page. The other controls on the AddEditInvestments page belong to a validation group called All Validators and the DropDownL...

.Net 2
Hi Friends, I want to show Different Tabs for different information on my web form ( .aspx page ). I could not found Tab Control with .net 2005. I know there is some but couldnt find it. Can you please tell me from where can I add Tab Control to my web form ? Thanks in advance, Nirav With some tedious settings of properties on the menu control, it will behave like a tab control.  Then you need to use a multiview control and fill it with views.  Then you need to wire up the menu to the multiview or something.  I tried this before and it works, but we wrote our own contro...

Running server controls compiled for .NET 1.1 in .NET 2.0
Hello, I have tried upgrading our ASP.NET 1.1 application to .NET 2.0 by using Web Application Projects, and it works beautifully. We use several 3rd party controls that we bought for use in .NET 1.1 and these seem to just work in .NET 2.0, except that I get an intermittent problem with one of them. Should DLLs compiled using .NET 1.1 simply work, except if they access classes that have been removed from the framework in .NET 2.0? If I have both .NET 1.1 and .NET 2.0 present on the machine and the ASP.NET application is configured to run using .NET 2.0 and I have a DLL compiled using .NE...

GridView control exporting to Excel in Net 2.0
Well, I did my homework and found 33,868 references to issues with the gridview control and Excel, none of which were close to whats happening with my app. I have a Gridview control on my VB.NET main page and when I right click on it the popup allows me to export to Excel just fine..5-6 columns, less than 100 rows..when I do the same on another page I get an Excel error popup : "This web query returned no data.."..both grids have a (Select) button in the 1st column. The one that works is simply that...the one that doesn't has the Button.Text defined as something e...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links http://en.wikipedia.org/wiki/.NET_Framework http://blogs.msdn.com/mohammadakif/archive/2006/12/03/net-3-0-different-versions-of-the-net-framework.aspx http://www.codeproject.com/aspnet/ComparisonASP1xASP20.aspAshok Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

Button image for each top level menu item
For the subpage items I am just going to use background images/styles, but for the top level menu items, I have a button for each one. Just to complicate matters I have a rollover image for each, so when the user's mouse hovers over a given menu item, the button swaps out so they see a different color. Can I do images for the top level menu items? Are rollovers possible as well? How? Appreciate any input. I'm still trying to figure this one out. Has anyone used buttons for their top level menu items? If you could copy the info from your web.sitemap + the css file that would be most help...

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

Unable to access page controls from base class in .NET 2.0 Beta 2
Hello All, I have converted a large-ish project to VS2005 beta 2. It is going better than beta 1, but it's still a world of pain. The latest problem is that I can't seem to access page controls from within a base class. I'm sure I didn't get this on beta 1 so maybe something has changed. Or maybe I'm just tired and it'll seem obvious tomorrow (it's the end of the working day here in the UK). Anyway, my problem: I have a page, Administration.aspx, a code behind file Administration.aspx.cs (with an Administration class), and, in a seperate project, a class called AdminPage. ...

Custom Control in .NET 2.0
Hi Friend ,                    I have to create one custom control that have some JS Script file and one web Server Control .                   Plz guide me how to create custom control .  Rajeev Kumar TiwariMicrosoft Professional Hi, From your description, you are wondering how can you develop a custom control involved with some javascript files and some web server controls, right? For you first question, ac...

Skin controls in .net 2.0
I have created a custom control in the app_code and have managed to skin it correctly (creating a pink and a blue skin) However when I place the vb code file in my class library with the following reference <%@ Register Assembly="WEM.Portal" Namespace="WEM.Portal.UI" TagPrefix="WEMui" %> it returns the following error. (Show in full below)  It seems to not resolve the WEM.Portal.UI.CollaspsingPanelThe ClassLibrary is called WEM.Portal and the class is started with the correct name space eg Namespace UI   Public Class Collaspsi...

Web resources about - Help! Find row on which a button was pressed in the gridview control in .NET 2.0 - asp.net.presentation-controls

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

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

DotNetKicks.com - Upcoming stories
DotNetKicks.com is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 11/25/2015 12:24:51 AM