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>