473,792 Members | 2,937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview ButtonFields - disabling based on same row data contion?

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="PendingGrid View" runat="server"
DataSourceID="P endingSqlDataSo urce"
AutoGenerateCol umns="False" DataKeyNames="P rocessId,DayTag "
SkinID="GridVie w" Width="600px">
<Columns>
<asp:BoundFie ld DataField="Proc essid" visible=false />
<asp:BoundFie ld DataField="DayT ag" HeaderText="Day Tag"
ReadOnly="True" SortExpression= "DayTag" />
<asp:BoundFie ld DataField="Carr ierCode"
HeaderText="Car rier Code" SortExpression= "CarrierCod e" />
<asp:BoundFie ld DataField="Last Action" HeaderText="Las t
Action" SortExpression= "LastAction " />
<asp:BoundFie ld DataField="Tota lRecords"
HeaderText="Tot al Records" SortExpression= "TotalRecor ds" />
<asp:ButtonFiel d ButtonType="But ton" Text="Rate"
HeaderText="Rat e" CommandName="Ra te" >
</asp:ButtonField >
<asp:ButtonFiel d ButtonType="But ton" Text="Export"
HeaderText="Exp ort" CommandName="Ex port">
</asp:ButtonField >
</Columns>
</asp:GridView>

Oct 16 '06 #1
3 12231

You can use something like

<asp:ButtonFiel d ButtonType="But ton" Text="Rate" HeaderText="Rat e"
CommandName="Ra te" Enabled=<%# IIF(Container.D ataItem("lastAc tion ") =
"Export Completed", "true","fal se" %>
>
Shahzad Godil
Karachi-Pakistan.

"jobs" <jo**@webdos.co mwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
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="PendingGrid View" runat="server"
DataSourceID="P endingSqlDataSo urce"
AutoGenerateCol umns="False" DataKeyNames="P rocessId,DayTag "
SkinID="GridVie w" Width="600px">
<Columns>
<asp:BoundFie ld DataField="Proc essid" visible=false />
<asp:BoundFie ld DataField="DayT ag" HeaderText="Day Tag"
ReadOnly="True" SortExpression= "DayTag" />
<asp:BoundFie ld DataField="Carr ierCode"
HeaderText="Car rier Code" SortExpression= "CarrierCod e" />
<asp:BoundFie ld DataField="Last Action" HeaderText="Las t
Action" SortExpression= "LastAction " />
<asp:BoundFie ld DataField="Tota lRecords"
HeaderText="Tot al Records" SortExpression= "TotalRecor ds" />
<asp:ButtonFiel d ButtonType="But ton" Text="Rate"
HeaderText="Rat e" CommandName="Ra te" >
</asp:ButtonField >
<asp:ButtonFiel d ButtonType="But ton" Text="Export"
HeaderText="Exp ort" CommandName="Ex port">
</asp:ButtonField >
</Columns>
</asp:GridView>

Oct 17 '06 #2

Shahzad Godil wrote:
You can use something like

<asp:ButtonFiel d ButtonType="But ton" Text="Rate" HeaderText="Rat e"
CommandName="Ra te" Enabled=<%# IIF(Container.D ataItem("lastAc tion ") =
"Export Completed", "true","fal se" %>
That really looked promising and powerful. However getting Getting
error:

ButtonField does not have a Databinding Event.

Oct 17 '06 #3
I was able to get this to work:

<asp:TemplateFi eld HeaderText="Tes t">
<ItemTemplate >
<asp:Button ID="Rate2" Text="Rate2" CommandName="Ra te2"
Enabled='<%# IIF(Container.D ataItem("LastAc tion").TRIM = "PENDING
APPROVAL...","T RUE","FALSE") %>' runat="server" />
</ItemTemplate>
</asp:TemplateFie ld>

Howevever, when I call the button, I'm unable to identify the row I'm
working with as follows now:

If e.CommandName = "Rate2" Then
Dim index As Integer = Convert.ToInt32 (e.CommandArgum ent)
Dim row As GridViewRow = PendingGridView .Rows(index)
Response.Write( row.Cells(3).Te xt)
End If

Giving me an error about the

Input string was not a correct format.

The above row logic worked fine when using FieldButton. Will I have no
choice but to use Findcontrol now?

Thanks!

Oct 17 '06 #4

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

Similar topics

3
2489
by: James Walker | last post by:
Hi there - hoping someone can help me here! I have a database that has been underperforming on a number of queries recently - in a test environment they take only a few seconds, but on the live data they take up to a minute or so to run. This is using the same data. Every evening a copy of the live data is copied to a backup 'snapshot' database on the same server and also, on this copy the queries only take a second or so to run....
4
5097
by: Hans Merkl | last post by:
Hi, Is there a way to show the column headers of a GridView control even if there is no data? The only thing I see is the EmptyDataTemplate but I would also like to display the column headers. Thanks Hans
0
1039
by: xmldig | last post by:
dot net 2.0 I have a gridview and I want to add a seperator line between rows of varying col1 values... Here is an example. col1 col 2 1 A 1 B 1 C <<INSERT SEPERATOR BAR HERE>>
1
1480
by: Hardik Shah | last post by:
Hi, I have created a entry module with data binding , I have two combo box with same data adapter with same data set. when I change the first combobox's value, there is automatically changed to second combo box also as it has same data adapter. If I want to use both combo box diffrently , how can I ? Hardik Shah.
3
14339
by: Rob Roberts | last post by:
Is there any way to add attributes to GridView ButtonFields? I'm looking for a way to add event handlers to ButtonFields. With regular ASP.NET buttons, I can add event handlers by using the Attributes collection, like this: MyButton.Attributes.Add("onmouseover", "this.className='actionH'"); MyButton.Attributes.Add("onmouseout", "this.className='actionN'"); But the GridView ButtonField doesn't seem to have an Attributes property. Is...
3
6019
by: Subrat Das | last post by:
Hi, I have a java application which calls a stored procedure to insert data into a table.Multiple threads of java call the same procedure at the same time. Sometimes it happens that few threads send the same data as parameter to the procedure. In that case i get the error : "Cannot insert duplicate key row in object ...." The functionality of the proc is - It checks if a given data (Based on Unique key) is present in the table or not. If...
1
1636
by: inamul | last post by:
I want to select CheckBox based on data retrieved from mysql database table. Could anyone show me the simple way of doing it. Data store in table under colum "sectionOfInterest" is shown below ------------------------------------------------------------------------ "Commercial Security Middle East, Homeland Security and Policing Middle East, " -----------------------------------------------------------------------------------
2
1961
by: Alexio | last post by:
Sample code snippet - <td align="right">Check Amount:&nbsp;</td> (1) <td><input type="text" name="CHK_input_1" size="19"style="text-align:right" onkeyup="calcCB();" onBlur="currency(this); calcCB();" tabindex="26"> (2) <input type="hidden" name="OBKey__53_1" id="kw_check_amount" > For various database reasons, I need to be able to populate a hidden field to be used as a keyword in our system based on the first...
5
2544
by: Christopher Brewster | last post by:
I am running the same script on the same data on two different machines (the folder is synchronised with Dropbox). I get two different results. All the script does is count words in different files and perform a simple set operation on the word lists. The laptop is a Macbook Pro (2 1/2 years old) running OS X 10.5.5 with Python 2.5.1 The desktop is an iMac (brand new) running OS X 10.5.5 also with Python 2.5.1 I have tried running the...
0
9670
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
9518
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
10159
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
10000
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
9033
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...
1
7538
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4111
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
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.