Solved

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

Posted on 2008-10-02
2
217 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

19 Experts available now in Live!

Get 1:1 Help Now