Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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