Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

756 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