473,782 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ 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 5851
Anybody have an idea ?

May 2 '06 #2
jh*****@gmail.c om'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.C ells[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
9805
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" AutoGenerateColumns="False" OnSelectedIndexChanged="gvOrderList_SelectedIndexChanged"> <Columns>
9
24811
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 page life cycle. In this example the event fires twice when a) GridView EnableViewState=False and any image type control in the <columns/> element. When either EnableViewState is set to true or the image button is removed, the event fires once....
0
1959
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 delete happens anyway. For example, I have a gridview like this : <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="GetOppsTypeList"...
0
3585
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 OleDbParameterCollection" whenI try to write a new record. Delete and Modify work fine its just the add record function causes the error.
3
12231
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 Completed" If this can't be done at the time I first bind, and I must use Findcontrol and by value, How can I do that? <asp:GridView ID="PendingGridView" runat="server" DataSourceID="PendingSqlDataSource"
4
4190
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 below. The event for RowDataBound is executed, rows get different color, but event for RowCommand is not executed. What could be the problem ? Thanks a lot in advance.
4
3487
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 below. The event for RowDataBound is executed, rows get different color, but event for RowCommand is not executed. What could be the problem ? Thanks a lot in advance.
0
3170
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 server-side operation, using the RowCommand functionality. In IE, this all works great, but in Firefox (v2.0.0.6), clicking the above mentioned ButtonField fires off two similar AJAX requests, which is causing errors in my server-side code. ...
0
4667
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 and also get the datakey (in my case personid) of the the rows selected. Please point me in the right direction. This is what i have so far but i have problem accessing the child gridview in the button click event Cheers, Shilpa. <asp:GridView...
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6735
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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 we have to send another system

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.