473,466 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

GridView and ButtonField type

Hi everybody,

I want to fill in a GridView with a dataset.
So I created the list of fields that I want to see in the gridview.
And I added a column (in first position in the gridview) as a
ButtonField column (ButtonType: button).
My records are loaded correctly.
During the RowDataBound event, I tried to change the Text of the button
for some records (depends of a check on others cells).

if (e.Row.Cells[12].Text == var.ToString())
e.Row.Cells[0].Text = "Cancel";
else
e.Row.Cells[0].Text = "Accept";

When I keep this check (and set), the text is changed, perfect.
But the type of my button is also changed.
That become a link type (ButtonType: link) and no more a "button" type.

Why ?
I don't understand what's happening :-{

If I don't perform my check (and set), the type of my ButtonField stays
"button".

Do you have a idea of what is wrong ?
Thanks in advance
Jerome

PS: I use the framework 2.0 (and VS2005).

Apr 30 '06 #1
3 5833
Anybody have an idea ?

May 2 '06 #2
jh*****@gmail.com's wild thoughts were released on 30 Apr
2006 11:14:01 -0700 bearing the following fruit:
Hi everybody,

I want to fill in a GridView with a dataset.
So I created the list of fields that I want to see in the gridview.
And I added a column (in first position in the gridview) as a
ButtonField column (ButtonType: button).
My records are loaded correctly.
During the RowDataBound event, I tried to change the Text of the button
for some records (depends of a check on others cells).

if (e.Row.Cells[12].Text == var.ToString())
e.Row.Cells[0].Text = "Cancel";
else
e.Row.Cells[0].Text = "Accept";

When I keep this check (and set), the text is changed, perfect.
But the type of my button is also changed.
That become a link type (ButtonType: link) and no more a "button" type.

Why ?
I don't understand what's happening :-{

If I don't perform my check (and set), the type of my ButtonField stays
"button".

Do you have a idea of what is wrong ?


You most likely need to change the text of the button not
the cell. I'm not sure how you'd achieve this if the button
is automatically generated but should be easy if you change
it to a template field.

Jan Hyde (VB MVP)

--
Women are like elephants to me. I like to look at them
but I wouldn't want to own one.

W.C. Fields

May 2 '06 #3
Hi,
I found the solution.
I need to get the first control of my first cell. It's my button field.

Button myButton = null;
myButton = (Button)e.Row.Cells[0].Controls[0];
myButton .Text = "Cancel";

Jerome

May 10 '06 #4

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

Similar topics

4
by: ber.janssens | last post by:
Hi, In ASP.NET 2.0, I have a GridView with 2 CommandFields, how can I determine in the SelectedIndexChanged event which CommandField is clicked? <asp:GridView ID="gvOrderList" runat="server"...
9
by: J055 | last post by:
Hi I have a very simple configuration of the GridView with paging and sorting. When I do a postback the DataBinding event fires twice - in both the ProcessPostData and PreRender stages of the...
0
by: Mike P | last post by:
When you specify updateparameters or deleteparameters for your gridview, I was under the impression that whether or not you write some code in the rowcommand event to deal with this, the update or...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
3
by: jobs | last post by:
Say I have Gridview with some Buttonfields I want to enable or disable based on the values of other bound data? Here I want I only want to enable button Rate only if field lastAction = "Export...
4
by: chris | last post by:
I have a perent gridview which includes in a template field a child gridview. Child gridview includes command buttons for opening different windows based on its row selected. I used the code...
4
by: =?Utf-8?B?Y2hyaXM=?= | last post by:
I have a perent gridview which includes in a template field a child gridview. Child gridview includes command buttons for opening different windows based on its row selected. I used the code...
0
by: jrnail23 | last post by:
I have a user control which contains an UpdatePanel, which contains a MultiView inside, with a GridView in one of the views. In my GridView, I have a ButtonField which is supposed to trigger a...
0
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
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
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,...
0
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.