Solved

How do I set set the label.text in a gridview FooterRow?

Posted on 2008-10-02
2
219 Views
Last Modified: 2008-10-02
I can't seem to set the text property of a label in a gridview FooterRow.  Stepping through with the debugger reveals I have found the correct control and I don't get any errors, but the label does not appear.  I assume it has something to do with viewstate and postback or something similiar.

The Try/Catch block is where I am attempting to set the label text.
Protected Sub InsertNewEmail(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim newdictionary As ListDictionary = New ListDictionary()

        Dim EmailAddress As String = CType(grdEmails.FooterRow.FindControl("txtNewEmailAddress1"), TextBox).Text

        Dim EmailType As String = CType(grdEmails.FooterRow.FindControl("ddlEmailTypes1"), DropDownList).SelectedValue

        Dim NewEmailAddress As String = EmailAddress

        Dim NewEmailTypeID As String = EmailType

        Dim NewPersonID As String = PersonID

        Dim NewUserID As Guid = UserID

        newdictionary.Add("EmailAddress", NewEmailAddress)

        newdictionary.Add("EmailTypeID", NewEmailTypeID)

        newdictionary.Add("PersonID", NewPersonID)

        newdictionary.Add("UserID", NewUserID)

        Try

            ldsPersonEmails.Insert(newdictionary)

        Catch ex As Data.SqlClient.SqlException

            Dim ExceptionLabel As Label = CType(grdEmails.FooterRow.FindControl("lblException"), Label)

            ExceptionLabel.Text = "Bad User!  Bad!"

        End Try

        grdEmails.DataBind()

    End Sub

Open in new window

0
Comment
Question by:abenage
2 Comments
 
LVL 18

Accepted Solution

by:
David Robitaille earned 500 total points
ID: 22627075
you problem is your  grdEmails.DataBind() that redraw the grdEmails
set your label outside the drid or try this

 

 Try

            ldsPersonEmails.Insert(newdictionary)

            grdEmails.DataBind()
 

        Catch ex As Data.SqlClient.SqlException

            Dim ExceptionLabel As Label = CType(grdEmails.FooterRow.FindControl("lblException"), Label)

            ExceptionLabel.Text = "Bad User!  Bad!"

        End Try

        

Open in new window

0
 
LVL 1

Author Comment

by:abenage
ID: 22627176
Thanks!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now