Solved

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

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

Independent Software Vendors: 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

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
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…

726 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