Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 7th, 2010, 09:34 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default GridView - conditional disabling of select button

I have a gridview with a select link (Not auto created)
One of my columns is a date column
Another column is essentially a 'group code'
For rows that have the same group code I want to disable or make the
link button not visible for all but the most recent row. So I have to operate on the rows as a group-can't look at each individually. I wasn't sure how to go about doing this.

Also-my button (shown right below) appears as link in ther grid:
I believe I will have to use FindControl in my solution but I don't know how to refer to this control. - Thanks



<asp:ButtonFieldCommandName="OfferDetail"Text="Offer Detail"ItemStyle-Width="150px"
ItemStyle-HorizontalAlign="Center">Thank you

Code:
<%@PageTitle=""Language="VB"MasterPageFile="~/secureds_deals.master" %>
<%@RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>
<scriptrunat="server">
ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs)
IfNot IsPostBack Then
'Dim statements deleted for this post on wrox
 
If Session("DealID") <= 0 Or Session("DealName") = ""Then Server.Transfer("Deals.aspx")
CmdGeNegotiationData.CommandType = Data.CommandType.StoredProcedure
dealidparam.Value = CInt(Session("DealID"))
CmdGeNegotiationData.Parameters.Add(dealidparam)
dealidparam.Direction = Data.ParameterDirection.Input
Conn.Open()
adapter = New SqlDataAdapter(CmdGeNegotiationData)
adapter.Fill(dataSet)


DealId = CInt(dataSet.Tables(0).Rows(0).ItemArray(0))
DealName = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(1), String)
StartDate = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(2), Date)
ContractDate = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(3), Date)
ClosingDate = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(4), Date)
SubmitRole = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(5), String)
Status = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(8), String)
OfferNumber = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(9), Int16)
OfferType = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(10), String)
OfferDateTime = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(11), Date)
PctDown = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(12), Int16)
OfferAmount = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(13), Int32)
SuggestedClosingDate = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(14), String)
CompletePct = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(15), Int16)
Guarantor = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(16), String)
Contingencies = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(17), String)
Notes = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(18), String)
AgentName = DirectCast(dataSet.Tables(0).Rows(0).ItemArray(19), String)
lblDealName.Text = "Deal Name: " & DealName
gvNegotiationGrid.DataSource = dataSet
gvNegotiationGrid.DataBind()



EndIf
EndSub
Sub gvNegotiationGrid_RowCommand(ByVal sender AsObject, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)

Dim rowindex AsInteger = e.CommandArgument

Session("offerid") = gvNegotiationGrid.DataKeys(rowindex).Value
Server.Transfer("deal.aspx")


EndSub
</script>
<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">
<asp:LabelID="lblDealName"runat="server"class="label"Text=""></asp:Label>
<divstyle="margin-top:25px;">
<asp:ButtonID="btnAddOffer"runat="server"Text="Add Offer"/>
</div>
<div>
<asp:GridViewID="gvNegotiationGrid"runat="server"HorizontalAlign="Center"CellPadding="4"GridLines="None"
Font-Names="Verdana,Arial"Font-Size="0.8em"AutoGenerateColumns="False"AutoGenerateSelectButton="true"
OnRowCommand="gvNegotiationGrid_RowCommand"
OnRowDataBound="gvNegotiationGrid_RowDataBound"ForeColor="#333333">
<RowStyleBackColor="#F7F6F3"ForeColor="#333333"BorderColor="#336699"BorderWidth="1"BorderStyle="Solid"/>
<Columns>
<asp:BoundFieldDataField="dealid"
HeaderText="Deal ID"/><asp:BoundFieldDataField="dealname"
HeaderText="Buyer/Seller"/><asp:BoundFieldDataField="SubmitRole"
HeaderText="Role"/><asp:BoundFieldDataField="AgentName"
HeaderText="Agent"/><asp:BoundFieldDataField="offertype"
HeaderText="Type"/><asp:BoundFieldDataField="offernumber"
HeaderText="#"/><asp:BoundFieldDataField="status"
HeaderText="Status"/><asp:BoundFieldHtmlEncode="false"DataFormatString="{0: $##,#}"DataField="offeramount"
HeaderText="Offer Amount"/><asp:BoundFieldDataField="pctdown"
HeaderText="% Down"/><asp:BoundFieldDataField="SuggestedClosingDate"
HeaderText="Suggested Close"/><asp:BoundFieldDataField="Guarantor"
HeaderText="Guarantor"/>
<asp:BoundFieldDataField="Notes"
HeaderText="Notes"
ItemStyle-Width="150px"><ItemStyleWidth="150px"></ItemStyle>
</asp:BoundField>
<asp:BoundFieldHtmlEncode="false"DataFormatString="{0:d}"DataField="offerdatetime"
HeaderText="Made On"/><asp:BoundFieldHtmlEncode="false"DataFormatString="{0:t}"DataField="offerdatetime"
HeaderText="At"/><asp:BoundFieldDataField="CompletePct"
HeaderText="Complete %"/><asp:ButtonFieldCommandName="OfferDetail"Text="Offer Detail"ItemStyle-Width="150px"
ItemStyle-HorizontalAlign="Center"><ItemStyleHorizontalAlign="Center"Width="150px"></ItemStyle>
</asp:ButtonField>
</Columns>
<FooterStyleBackColor="#5D7B9D"Font-Bold="True"ForeColor="White"/>
<PagerStyleBackColor="#284775"ForeColor="White"HorizontalAlign="Center"/>
<SelectedRowStyleBackColor="#E2DED6"Font-Bold="True"ForeColor="#333333"/>
<RowStyleHorizontalAlign="Center"/>
<HeaderStyleBorderColor="#336699"BorderStyle="Solid"BorderWidth="1px"Font-Names="Verdana"Font-Size="Small"HorizontalAlign="Center"VerticalAlign="Top"BackColor="#5D7B9D"Font-Bold="True"ForeColor="White"/>
<EditRowStyleBackColor="#999999"/>
<AlternatingRowStyleBorderColor="#336699"BorderStyle="Solid"BorderWidth="1px"HorizontalAlign="Center"BackColor="White"ForeColor="#284775"/>
</asp:GridView>
<asp:SqlDataSourceID="dsNegotiationGrid"runat="server"
ConnectionString="<%$ ConnectionStrings:DB_6056_securedeConnectionString %>">
</asp:SqlDataSource>
</div>
</asp:Content>
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
disabling a button with textbox sh_erfan C# 4 December 21st, 2009 01:56 PM
disabling a button with textbox sh_erfan C# 0 November 2nd, 2009 08:35 PM
Select row in GridView WITHOUT using Select button rao965 ASP.NET 2.0 Professional 1 February 15th, 2008 10:44 AM
Disabling browser's "X" button farhanzia Javascript 1 July 9th, 2003 10:04 AM



All times are GMT -4. The time now is 05:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.