Solved

set label to parameter value

Posted on 2012-04-04
3
303 Views
Last Modified: 2012-05-16
hello

I am trying to set ASP.NET label values to values from an SQL parameter. I have around 300 parameters and I have a solution, but it is slow.

my labels are all named lblname and my parameters are all pname

see code:

 For Each p As SqlParameter In cmdselect.Parameters
           ' build a string with label name
            If p.Value IsNot Nothing  Then
                labelid = "lbl" + p.ParameterName.Substring(1, p.ParameterName.Length - 1)
                Try
                    Dim myControl1 As Label = CType(FindControl(labelid), Label)
                    If myControl1.ID = labelid Then
                        myControl1.Text = p.Value
                    End If
              Catch ex As Exception
               End Try
           End If
       Next
  
'

Open in new window


The above works but is slow, thinking I should maybe create an array in the INIT routine with the names of the control and what the parmeter names are, somthing like

 the above works, but is slow, thinking I need
       Dim ctl As Control
      dim ctlarray as array
        Dim mypanel As View
        mypanel = FindControl("viewbudetrypricing")

        For Each ctl In mypanel.Controls
          ctlarray(count) = ctl.id
        Next

Open in new window


thanks for any help.
0
Comment
Question by:Graham_Forbes
  • 2
3 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37808187
I dont think that would help as in the end you are looping through the parameter collection and you are using the FindControl which both are slow processes. Why 300 parameters? May be you should rethink your approach.
0
 

Accepted Solution

by:
Graham_Forbes earned 0 total points
ID: 37808280
at the moment i am matching the SQL parameters to the labels on each call to the SQL procedure. if I could capture the match in an array as the page loads or INIT that would make it much faster.

its a complicated web page for use within our company, with lots of fields to caputure, hence the 300 parameters.

thanks
0
 

Author Closing Comment

by:Graham_Forbes
ID: 37974352
no answer
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 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

17 Experts available now in Live!

Get 1:1 Help Now