473,480 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

another ButtonField Problem

hey

asp.net 2.0

Below I'm trying to specify a ButtonField. The problem is that when I click
on the ButtonField (CommandName = UserName) I don't get info the UserName in
the gvwUsers_RowCommand. In the code below I'm trying to assign a variable
the value of "UserName" column (string username = gridRow.Cells[0].Text;)
but the variable get set to ""...

I need the value of UserName so can use it in a URL

Any suggestions?

<Columns>
<asp:ButtonField HeaderText="UserName" CommandName="UserName"
DataTextField="UserName" />
<asp:ButtonField HeaderText="Occupation" CommandName="Occupation"
DataTextField="Occupation" />
<asp:ButtonField HeaderText="Country" CommandName="Country" />
</Columns>

protected void gvwUsers_RowCommand(Object sender, GridViewCommandEventArgs
e)
{
if (e.CommandName == "UserName")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow gridRow = gvwUsers.Rows[index];
string username = gridRow.Cells[0].Text;
Response.Redirect("~/User.aspx?user=" + username);
}
}
Oct 27 '06 #1
0 1024

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6199
by: Edwin Knoppert | last post by:
I post this again, no answer before. During the beta version it worked, the same code does no longer work in the new release. I have a simple gridview with ButtonField, the button deletes a...
1
4866
by: lanem | last post by:
I have a gridview. One of the columns is a buttonfield. I use the datatextfield property of buttonfield to show my bound value as a hyperlink in each buttonfield cell. I then want to get that...
2
20598
by: Rob Roberts | last post by:
Is there any way to prevent a ButtonField in a GridView from doing a postback when clicked? I want to use my own onclick handler to call window.open('SomePage.aspx') to display a page in a new...
1
4478
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I am using ASP.Net 2.0 themes, and have a GridView with a ButtonField column. I can not find a way to create a style for ButtonField columns in the application's theme, specifically, I want to set...
3
22510
by: GaryDean | last post by:
I have a button field in a gridview defined as follows: <asp:ButtonField ButtonType="Button" CommandName="AcceptOrder" Text="Accept Whole Order"> <ControlStyle Font-Size="X-Small" />...
0
2195
by: codeshelp | last post by:
I have a gridview that has a ButtonField(Insert) that calls a detailsview which allows you to insert data to the gridview. The postback for this buttonField is:...
3
3516
by: pbd22 | last post by:
Hi. How do I add the runat=server attribute on a buttonfield link dynamically? thanks!
2
10394
by: Elmo Watson | last post by:
I've converted a buttonfield to a TemplateField with a button in it Previously, in the Rowcommand, to identify the row when the ButtonField was clicked, I had this code: Dim index As Integer =...
1
2015
by: JLC | last post by:
For some reason I am getting this error. Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField' Here is my code for my .aspx file <asp:ButtonField...
0
6903
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7027
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7071
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...
0
6861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5318
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4763
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4468
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2974
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
170
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.