Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2006, 07:37 AM
Authorized User
 
Join Date: Aug 2006
Posts: 39
Thanks: 1
Thanked 0 Times in 0 Posts
Default To get text of Button Field column in GridView

:)Hello,

I have designed a GridView with two columns. One is ButtonField type which is bound with "Customer_Name" field and second BoundColumn type with "Company" field.

I want to store text of cell of ButtonField column of any row. My code is as below.

private void CustomersGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
{
  if (e.CommandName == "Select")
  {
    int index = Convert.ToInt32(e.CommandArgument);
    GridViewRow selectedRow = CustomersGridView.Rows[index];
    string strValue = selectedRow.Cells[1].Text;

    Response.Write(strValue);
    //As above line returns the text of column 2. Here I want to return text of column 1. How?????
   }
}

Please give me the solution. Thanks.:)

 
Old November 3rd, 2006, 10:57 AM
Authorized User
 
Join Date: Nov 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to davidrodrigues40
Default

You should just have to change the Cells[1] to Cells[0] and that should work. Columns are numbered from 0 to ...






Similar Threads
Thread Thread Starter Forum Replies Last Post
Get GridView Cell Value Based on GridView Column stublair C# 2008 aka C# 3.0 0 September 4th, 2008 08:30 AM
Dynamic changing value of a gridview button text elwappo ASP.NET 2.0 Professional 6 January 7th, 2008 07:39 AM
how to set tabindex in gridview(Button column) amolchikurte ASP.NET 2.0 Professional 2 May 29th, 2007 11:54 PM
Image Button as Template Field in GridView control vbmazza ASP.NET 2.0 Professional 10 May 27th, 2007 10:03 AM
To get text of ButtonField column in GridView nitinp ASP.NET 2.0 Professional 11 May 26th, 2007 12:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.