D
David C
I have a GridView that I need to grab the value in a non-visible BoundField
and I cannot seem to get it to work. Can someone please help. I am trying
to get the value in the PropertyID BoundField. Below is the sub and the
GridView columns definition for the GridView named gvPropertyClosings.
Thank you.
David
Protected Sub gvPropertyClosings_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs)
Dim gvrow As GridViewRow = gvPropertyClosings.SelectedRow
txtSaleOrLease.Text = Left(gvrow.Cells(6).Text, 1)
txtClosingID.Text = gvPropertyClosings.SelectedValue
txtClosingName.Text = gvrow.Cells(4).Text
If Request.QueryString("prop") = "0" Then
'PropertyID = 0 so not linked to a property
'Show deal name at top of screen instead of address
txtAddressTop.Text = Server.HtmlDecode(gvrow.Cells(4).Text)
End If
If gvrow.Cells(3).Text = "" Then
'No closing date and may be new closing so put form into edit
mode
'if user has admin rights.
'Get auth level from cookie named level set in default.aspx
If Not Request.Cookies("level") Is Nothing Then
Dim strLevel As String
strLevel = Server.HtmlEncode(Request.Cookies("level").Value)
If strLevel = "admin" Then
fvPropertyClosings.ChangeMode(FormViewMode.Edit)
End If
End If
End If
Dim strPropertyID As String =
Convert.ToString(DataBinder.Eval(gvrow.DataItem, "PropertyID"))
txtPropertyID.Text = strPropertyID
If strPropertyID <> "0" And strPropertyID <> "" Then
'Set PostBackUrl for Documents and Back to Listing link buttons
LBtnDocuments.PostBackUrl = "~/frmListingDocs.aspx?p=" &
strPropertyID & "&t=close"
LBtnListing.PostBackUrl = "~/frmProperty.aspx?p=" &
strPropertyID
LBtnDocuments.CssClass = "Show"
LBtnListing.CssClass = "Show"
Else
LBtnDocuments.PostBackUrl = "~/frmListingDocs.aspx?p=0&t=close"
LBtnDocuments.CssClass = "Show"
LBtnListing.CssClass = "Hide"
End If
End Sub
Below are the columns in the GridView
<Columns>
<asp:CommandField ShowSelectButton="True"
SelectText="Details" ShowCancelButton="false">
<ItemStyle ForeColor="Blue" />
</asp:CommandField>
<asp:BoundField DataField="ClosingID" HeaderText="ClosingID"
InsertVisible="False"
ReadOnly="True" SortExpression="ClosingID"
Visible="False" />
<asp:BoundField DataField="PropertyID"
HeaderText="PropertyID" SortExpression="PropertyID"
Visible="False" />
<asp:BoundField DataField="DateClosed" HeaderText="Closed"
SortExpression="DateClosed" DataFormatString="{0:d}" HtmlEncode="False" />
<asp:BoundField DataField="ClosingName" HeaderText="Deal"
SortExpression="ClosingName" >
<ControlStyle Width="200px" />
</asp:BoundField>
<asp:BoundField DataField="LeaseSaleCode"
HeaderText="LeaseSaleCode" SortExpression="LeaseSaleCode" Visible="False" />
<asp:BoundField DataField="LeaseSaleText" HeaderText="Type"
SortExpression="LeaseSaleText" />
</Columns>
and I cannot seem to get it to work. Can someone please help. I am trying
to get the value in the PropertyID BoundField. Below is the sub and the
GridView columns definition for the GridView named gvPropertyClosings.
Thank you.
David
Protected Sub gvPropertyClosings_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs)
Dim gvrow As GridViewRow = gvPropertyClosings.SelectedRow
txtSaleOrLease.Text = Left(gvrow.Cells(6).Text, 1)
txtClosingID.Text = gvPropertyClosings.SelectedValue
txtClosingName.Text = gvrow.Cells(4).Text
If Request.QueryString("prop") = "0" Then
'PropertyID = 0 so not linked to a property
'Show deal name at top of screen instead of address
txtAddressTop.Text = Server.HtmlDecode(gvrow.Cells(4).Text)
End If
If gvrow.Cells(3).Text = "" Then
'No closing date and may be new closing so put form into edit
mode
'if user has admin rights.
'Get auth level from cookie named level set in default.aspx
If Not Request.Cookies("level") Is Nothing Then
Dim strLevel As String
strLevel = Server.HtmlEncode(Request.Cookies("level").Value)
If strLevel = "admin" Then
fvPropertyClosings.ChangeMode(FormViewMode.Edit)
End If
End If
End If
Dim strPropertyID As String =
Convert.ToString(DataBinder.Eval(gvrow.DataItem, "PropertyID"))
txtPropertyID.Text = strPropertyID
If strPropertyID <> "0" And strPropertyID <> "" Then
'Set PostBackUrl for Documents and Back to Listing link buttons
LBtnDocuments.PostBackUrl = "~/frmListingDocs.aspx?p=" &
strPropertyID & "&t=close"
LBtnListing.PostBackUrl = "~/frmProperty.aspx?p=" &
strPropertyID
LBtnDocuments.CssClass = "Show"
LBtnListing.CssClass = "Show"
Else
LBtnDocuments.PostBackUrl = "~/frmListingDocs.aspx?p=0&t=close"
LBtnDocuments.CssClass = "Show"
LBtnListing.CssClass = "Hide"
End If
End Sub
Below are the columns in the GridView
<Columns>
<asp:CommandField ShowSelectButton="True"
SelectText="Details" ShowCancelButton="false">
<ItemStyle ForeColor="Blue" />
</asp:CommandField>
<asp:BoundField DataField="ClosingID" HeaderText="ClosingID"
InsertVisible="False"
ReadOnly="True" SortExpression="ClosingID"
Visible="False" />
<asp:BoundField DataField="PropertyID"
HeaderText="PropertyID" SortExpression="PropertyID"
Visible="False" />
<asp:BoundField DataField="DateClosed" HeaderText="Closed"
SortExpression="DateClosed" DataFormatString="{0:d}" HtmlEncode="False" />
<asp:BoundField DataField="ClosingName" HeaderText="Deal"
SortExpression="ClosingName" >
<ControlStyle Width="200px" />
</asp:BoundField>
<asp:BoundField DataField="LeaseSaleCode"
HeaderText="LeaseSaleCode" SortExpression="LeaseSaleCode" Visible="False" />
<asp:BoundField DataField="LeaseSaleText" HeaderText="Type"
SortExpression="LeaseSaleText" />
</Columns>