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 8727463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:26:19+00:00 2026-06-13T08:26:19+00:00

I am working in an application in which user selects some rows in a

  • 0

I am working in an application in which user selects some rows in a gridview by clicking on check boxes associated with each row and in selected rows only one value should be updated in database.
I am using following query

 update Items
 set bitIsTab = 1
 where ReqID = 3

Suppose that user selects 4 values from gridview and i have to set these 4 rows bitIsTab to 1.How to update these rows by calling query one time or i have to call the same query as many times as the number of records selected.

  • 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-06-13T08:26:20+00:00Added an answer on June 13, 2026 at 8:26 am

    Okay the query should look like this, to update items 1,2,3,4:

     UPDATE Items
     SET bitIsTab = 1
     WHERE ReqID IN (1,2,3,4);
    

    It can however be done using Linq:

    List<int> selectedIds = { 1, 2, 3, 4 };
    var itemsToBeUpdated = (from i in yourContext.Items 
                            where selectedIds.Contains(i.ReqID)
                            select i);
    itemsToBeUpdated.ForEach(i=>i.bitIsTab = 1);
    yourContext.SubmitChanges();
    

    Or you could use a VARCHAR in your stored procedure:

    CREATE PROCEDURE sp_setTabItems
        @ids varchar(500) AS
     UPDATE Items
     SET bitIsTab = 1
     WHERE charindex(',' + ReqID + ',', ',' + @ids + ',') > 0;
    

    And then use “1,2,3,4” as your stored procedure parameter.

    To execute the stored procedure:

     EXEC sp_setTabItems '1,2,3,4'
    

    Could also be done in a more reusable way, with the bitIsTab as a parameter:

    CREATE PROCEDURE sp_setTabItems
        @isTab bit,
        @ids varchar(500) AS
     UPDATE Items
     SET bitIsTab = @isTab 
     WHERE charindex(',' + ReqID + ',', ',' + @ids + ',') > 0;
    

    And executed this way:

    EXEC sp_setTabItems '1,2,3,4',1
    

    I updated the stored procedure solution, since comparing a INT with a VARCHAR won’t work with the EXEC.

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

Sidebar

Related Questions

I am working on an iPhone application which uses various colors. When user selects
I am working on an application in which a user is allowed to fill
I have been working on an application which allows the user to make a
I'm working on an application for iOS which will have the user fill out
I'm working on an application where when a user selects a menu item they
I'm working on application and I need some suggestions which is the best way
I have an application in which a user can pass in some or all
I am working on a kiosk application which gives the user a selection of
I am working on application which needs to be authenticated in different domain. To
i am working on one application which requires the feature of adding the custom

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.