Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6646685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:26:48+00:00 2026-05-26T00:26:48+00:00

I’m attempting to reference the text from a label in a DetailsView in my

  • 0

I’m attempting to reference the text from a label in a DetailsView in my CodeBehind, then pass it through a Stored Procedure.

My DetailsView is DetailsView1, and the two fields are lblDialID & lblCallbackID. I’ve converted them to TemplateFields. The data is populating properly, but when I’m attempting to grab the data and pass it, I’m not getting any results.

The Stored Procedure is not performing it’s action, and a Response.Write on the variables does not produce any results so assumedly I’m just grabbing thin air 🙂

Any guidance here?

Protected Sub lnkCBtoPUB_Click(ByVal sender As Object, ByVal e As EventArgs)    
Dim Conn As New SqlConnection("Data Source=SERVER;Initial Catalog=DATABASE;User ID=USER;Password=PASSWORD")
Dim MyCommand As New SqlCommand
Dim sDialID As Label = CType(DetailsView1.FindControl("lblDialID"), Label)
Dim sCallbackID As Label = CType(DetailsView1.FindControl("lblCallbackID"), Label)

Conn.Open()
MyCommand.Connection = Conn
MyCommand.CommandType = CommandType.StoredProcedure
MyCommand.CommandText = "spAlterAgentCallback"
MyCommand.Parameters.AddWithValue("@DialID", sDialID.Text)
MyCommand.Parameters.AddWithValue("@CallbackID", sCallbackID.Text)

MyCommand.ExecuteNonQuery()

Conn.Close()
Conn.Dispose()
MyCommand.Dispose()
End Sub

Here is the Stored Procedure

ALTER PROCEDURE [dbo].[spAlterAgentCallback]
@DialID AS INT,
@CallBackID AS INT
AS
BEGIN
UPDATE DIAL 
SET CBDATETIME = GETDATE(),
AgentID = '',
CRC = 'SCBR',
Notes = 'This Record Was Recently a Callback for Another Agent.'
WHERE DialID = @DialID

DELETE FROM CALLBACK WHERE CallBackID = @CallBackID
END 

<>
Could this also be because I am passing a string, but the SP is taking it as an INT? This shouldn’t pose a problem though?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:26:49+00:00Added an answer on May 26, 2026 at 12:26 am

    Looks like in your AddWithValue, you need to access the Text Property of the Labels instead of passing the Label object into the proc and you should be okay.

    So:

    MyCommand.Parameters.AddWithValue("@DialID", sDialID.Text)
    MyCommand.Parameters.AddWithValue("@CallbackID", sCallbackID.Text)
    

    If you weren’t getting the controls, it would have thrown a NullReferenceException.

    EDIT:

    As for the SP you need to isolate where the issue is occurring. Try running the SProc from SQL Management Studio giving the parameters that .NET would pass in and confirm the proc is running. If it does work, I would debug your code to make sure the values make it into the parameters. The Integer type shouldn’t matter because .NET looks up the type later. If you wanted to be safe, you could parse them into integer’s before sending them to the Proc.

    EDIT2:

    You could try using Hidden Fields in this way:

    (Somewhere in your detailsview)

    <asp:HiddenField ID="_CtlDialIDHidden" runat="server" Value='<%#Eval("DialID")%>' />
    <asp:HiddenField ID="_CtlCallbackIDHidden" runat="server" Value='<%#Eval("CallbackID")%>' />
    

    And in your click event

    If Request.Form.AllKeys.Contains("_CtlDialIDHidden") Then
        MyCommand.Parameters.AddWithValue("@DialID",  Request.Form.Item(Request.Form.AllKeys.FirstOrDefault(Function(x As String) x.Contains("_CtlDialIDHidden"))))
    End If
    If Request.Form.AllKeys.Contains("_CtlCallbackIDHidden") Then
        MyCommand.Parameters.AddWithValue("@CallbackID",  Request.Form.Item(Request.Form.AllKeys.FirstOrDefault(Function(x As String) x.Contains("_CtlCallbackIDHidden"))))
    End If
    

    You may have to view source to see exactly what the name being passed back is instead of using the lambda expressions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of posts stored in text files formatted in yaml/textile (from
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I have a reasonable size flat file database of text documents mostly saved in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.