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

  • SEARCH
  • Home
  • 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 4026214
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:56:32+00:00 2026-05-20T10:56:32+00:00

Problem: When adding list item the Value field is being set to the Text

  • 0

Problem:
When adding list item the Value field is being set to the Text field. Initially I though the problem was related to the input parameter for the primary key ( group_type_id ) as it is configured as OUTPUT variable.

Interesting enough, when I Watch all of the values, everything is correct.
So for example, I’ll watch these:

ddr["group_type_name"]   comes out as "Dept"
ddr["grouptypeid"] comes out as 4

When the item is created however,

itms.TEXT = "Dept"
itms.Value = "Dept"  <-- THIS IS THE PROBLEM

I’m at a loss why the listbox values are being set to the text values when I can clearly see the data reader values are correct. ?

Code sample here:

DbDataReader ddr = grp.GetGroupTypeList(grp);
if (ddr.HasRows)
{
    ListItem itm = new ListItem();
    itm.Text = "Select Group";
    itm.Value = "0";
    lb.Items.Add(itm);
    while (ddr.Read())
    {
        ListItem itms = new ListItem(ddr["group_type_name"] as string, ddr["grouptypeid"] as string);
    }
    lb.SelectedValue = lbSelected;            
}

procedure:

ALTER PROCEDURE [dbo].[asp_Group_Type]
@driver             char(1)='I',
@group_type_id      int=null OUTPUT,
@group_type_name    varchar(50)=null,
@par_group_id       int=null,
@active             bit 
AS
DECLARE @SQL    varchar(8000)
DECLARE @boolWhere varchar(10)
SET @boolWhere = ' WHERE ' 

SET NOCOUNT ON

IF (@driver = 'I')
    BEGIN
        INSERT INTO  [dbo].[group_type]
       ([group_type_name],
        [Par_Group_Id])
     VALUES
       (RTRIM(LTRIM(@group_type_name)),
        @par_group_id)

        SELECT @group_type_id = SCOPE_IDENTITY() 
    END

IF (@driver = 'U')
    BEGIN
        UPDATE  [dbo].[group_type]
           SET [group_type_name] = RTRIM(LTRIM(@group_type_name))
              ,[Par_Group_Id] = @par_group_id
         WHERE [group_type_id] = @group_type_id
    END

IF (@driver = 'S')
    BEGIN


        SET @SQL = ' SELECT  [group_type_id] AS [grouptypeid], [group_type_id], [group_type_name],[Par_Group_Id]  FROM [dbo].[group_type] '

        IF (@group_type_id > 0)
            BEGIN
                SET @SQL = @SQL + @boolWhere + '[group_type_id] = ''' + CAST(@group_type_id AS VARCHAR) + ''''
                SET @boolWhere = ' AND '
            END 

        IF (@active > 0)
            BEGIN
        SET @SQL = @SQL + @boolWhere + ' [active] = ''' + CAST(@active AS VARCHAR) + ''''
            END 

        SET @SQL = @SQL + ' ORDER BY [group_type_name] '
        PRINT(@SQL)
        EXEC(@SQL)
    END
  • 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-20T10:56:33+00:00Added an answer on May 20, 2026 at 10:56 am

    It’s almost certainly the as string that is causing the problems. “as” will default to null if it can’t do the conversion. A ListItem will set the Value to the same as the Text if the Value isn’t a valid string. Instead use ddr["grouptypeid"].ToString().

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

Sidebar

Related Questions

I'm having a problem adding a reference to a .NET assembly I built. Here's
Problem: I have an address field from an Access database which has been converted
Problem: Given a list of strings, find the substring which, if subtracted from the
Problem is described and demonstrated on the following links: Paul Stovell WPF: Blurry Text
Related to this: Adding new items dynamically to IQueryable hard-coded fake repository How could
I've got some problems adding a excel document as attachment on a custom list.
I have problem while adding a child to a GtkVBox. The VBox is inside
I have a panel hide/show setup that is triggered from a list item anchor.
Hi im trying to create a list adding to it via a for loop
Im having problem's adding map markers to gmaps using jquery. Here is my code

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.