?
Solved

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

Posted on 2008-10-02
2
Medium Priority
?
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
David Robitaille earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

764 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