473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

won't find buttonfield?

34
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

Expand|Select|Wrap|Line Numbers
  1.   <asp:ButtonField ItemStyle-Wrap="false" ButtonType="Link" HeaderText="Status" DataTextField="clusterStatusName" CommandName="update" />
and here is the code in my aspx.cs file where it is choking.

Expand|Select|Wrap|Line Numbers
  1. clusterStatusLink = (ButtonField)GridView1.Rows[j].FindControl(ColumnClusterStatusName);
I want to find thi control, the buttonfield, and change the color of it. When I had this as a label I was able to get it to work no problem, but when I change it to a buttonfield, I get that error and not sure how to fix it.

can anyone lend a hand?

Thanks!
Mar 4 '08 #1
1 2014
Hi,

I think problem is in typecasting. When you try to typecast control in codebehind then you should prefix the namespace.

Instead of

clusterStatusLink = (ButtonField)GridView1.Rows[j].FindControl(ColumnClusterStatusName);



try this one.

clusterStatusLink = (System.Web.UI.WebControls.ButtonField)GridView1.R ows[j].FindControl(ColumnClusterStatusName);


Thanks

Mahesh.




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

Expand|Select|Wrap|Line Numbers
  1.   <asp:ButtonField ItemStyle-Wrap="false" ButtonType="Link" HeaderText="Status" DataTextField="clusterStatusName" CommandName="update" />
and here is the code in my aspx.cs file where it is choking.

Expand|Select|Wrap|Line Numbers
  1. clusterStatusLink = (ButtonField)GridView1.Rows[j].FindControl(ColumnClusterStatusName);
I want to find thi control, the buttonfield, and change the color of it. When I had this as a label I was able to get it to work no problem, but when I change it to a buttonfield, I get that error and not sure how to fix it.

can anyone lend a hand?

Thanks!
Mar 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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
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
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...
3
by: jhaidon | last post by:
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...
0
by: Jeff | last post by:
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...
3
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" />...
3
by: pbd22 | last post by:
Hi. How do I add the runat=server attribute on a buttonfield link dynamically? thanks!
0
by: Moneypenny | last post by:
Hi there, I have a Gridview control which has a dropdownlist in every row. The dropdowns are populated dynamically from a database (so the content is different in each row. There is also a select...
2
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 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.