Getting BoundField value in GridView problem

Getting BoundField value in GridView problem

am 11.01.2008 22:47:36 von 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



SelectText="Details" ShowCancelButton="false">


InsertVisible="False"
ReadOnly="True" SortExpression="ClosingID"
Visible="False" />
HeaderText="PropertyID" SortExpression="PropertyID"
Visible="False" />
SortExpression="DateClosed" DataFormatString="{0:d}" HtmlEncode="False" />
SortExpression="ClosingName" >


HeaderText="LeaseSaleCode" SortExpression="LeaseSaleCode" Visible="False" />
SortExpression="LeaseSaleText" />

Re: Getting BoundField value in GridView problem

am 11.01.2008 23:38:21 von David Wier

have you tried making it a TemplateField, and then add a non-visible label,
to hold the data?

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup


"David C" wrote in message
news:e4S48uJVIHA.5208@TK2MSFTNGP04.phx.gbl...
>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
>
>
>
> > SelectText="Details" ShowCancelButton="false">
>
>

> > HeaderText="ClosingID" InsertVisible="False"
> ReadOnly="True" SortExpression="ClosingID"
> Visible="False" />
> > HeaderText="PropertyID" SortExpression="PropertyID"
> Visible="False" />
> > SortExpression="DateClosed" DataFormatString="{0:d}" HtmlEncode="False" />
> > SortExpression="ClosingName" >
>
>

> > HeaderText="LeaseSaleCode" SortExpression="LeaseSaleCode" Visible="False"
> />
> > SortExpression="LeaseSaleText" />
>

>
>

Re: Getting BoundField value in GridView problem

am 14.01.2008 15:50:42 von David C

Tried that and it still does not pick up the PropertyID value.

David
"David Wier" wrote in message
news:OeJ2tKKVIHA.4808@TK2MSFTNGP05.phx.gbl...
> have you tried making it a TemplateField, and then add a non-visible
> label, to hold the data?
>
> David Wier
> http://aspnet101.com
> http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with
> no bloated markup
>
>
> "David C" wrote in message
> news:e4S48uJVIHA.5208@TK2MSFTNGP04.phx.gbl...
>>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
>>
>>
>>
>> >> SelectText="Details" ShowCancelButton="false">
>>
>>

>> >> HeaderText="ClosingID" InsertVisible="False"
>> ReadOnly="True" SortExpression="ClosingID"
>> Visible="False" />
>> >> HeaderText="PropertyID" SortExpression="PropertyID"
>> Visible="False" />
>> >> SortExpression="DateClosed" DataFormatString="{0:d}" HtmlEncode="False"
>> />
>> >> SortExpression="ClosingName" >
>>
>>

>> >> HeaderText="LeaseSaleCode" SortExpression="LeaseSaleCode" Visible="False"
>> />
>> >> HeaderText="Type" SortExpression="LeaseSaleText" />
>>

>>
>>
>
>