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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:07:59+00:00 2026-05-15T01:07:59+00:00

I have a ASPX.NET DataGrid and im trying to USE a select LIKE ‘X’%

  • 0

I have a ASPX.NET DataGrid and im trying to USE a select LIKE ‘X’% from a table that has 1 field called location. im trying to display the locations that start with a certain letter (example wxxx,axxx,fxxx,) in different columns in my data grid.

I am trying to display more than 1 column in my datagrid using a SP shown below. The issue is that the table locationMaster has only 1 field called location. The field Location has mutable location numbers that start with different letters (example w1002, w1003, 00159, 00526). What I would like to do is use a sp to display the wxxxx locations in one column in my datagrid and 0xxxx in another. If i just simply run

SELECT DISTINCT 
    LM.LOCATION AS 'LOCATIONS', 
    LM.COUNTLEVEL AS 'COUNTLEVEL' 
FROM  
    SOH S WITH(NOLOCK)  
JOIN LOCATIONMASTER LM ON LM.LMID = S.LMID 
WHERE 
    LM.COUNTLEVEL = 1 
    AND LM.LOCATION NOT IN ('RECOU','PROBLEM','TOSTOCK','PYXVLOC')

My Datagrid has only 1 column with all the locations and the page will be very lengthy
If i could somehow use LIKE ‘W%’ AND LIKE ‘0%’ in a sp and create two columns

SELECT
  DISTINCT LM.LOCATION AS '0 LOCATIONS' ,
    LM.COUNTLEVEL AS 'COUNTLEVEL'
FROM  SOH S WITH(NOLOCK)
  JOIN LOCATIONMASTER LM ON LM.LMID = S.LMID
WHERE
   LM.COUNTLEVEL = 1 AND
   LM.LOCATION NOT IN ('RECOU','PROBLEM','TOSTOCK','PYXVLOC')
   AND LM.LOCATION LIKE '0%'

SELECT
   DISTINCT LM.LOCATION AS 'A LOCATIONS' ,
   LM.COUNTLEVEL AS 'COUNTLEVEL'
FROM  SOH S WITH(NOLOCK)
  JOIN LOCATIONMASTER LM ON LM.LMID = S.LMID
WHERE
   LM.COUNTLEVEL = 1 AND
   LM.LOCATION NOT IN ('RECOU','PROBLEM','TOSTOCK','PYXVLOC')
   AND LM.LOCATION LIKE 'A%'**

And here is my datagrid code

<Columns>
    <asp:BoundColumn DataField="COUNTLEVEL" Visible="false"/>
    <asp:TemplateColumn HeaderText="LOCATION">
       <ItemTemplate>
          <a href='confirmRecount.aspx?Var=<%# DataBinder.Eval(Container.DataItem ,"0 LOCATIONS")%>'>
          <%# DataBinder.Eval(Container.DataItem, "0 LOCATIONS")%>
          </a>
       </ItemTemplate>
    </asp:TemplateColumn>
</Columns>
  • 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-15T01:07:59+00:00Added an answer on May 15, 2026 at 1:07 am

    What you want to do is not realy logical, data in a row relates to other data in that row it could not be done with a simple SQL select. Let’s say you had a small table with 2 rows:

    **LOCATION**         **COUNTLEVEL**
       W1234                  10
       A7654                  23
    

    Now you want to transform it so that W1234 and A7654 were in 2 different columns. What would happen to the count level field. You would then have 1 row with theee columns and you would have 2 count levels that no longer related to their respective rows they would now relate to different columns, what would go in the count level column? So you would have to try and do something like this:

    **LOCATION A**  **COUNTLEVELA**   **LOCATION W**   **COUNTLEVELW**
        NULL             NULL              W1234             10   
       A7654             23                 NULL            NULL 
    

    But i don’t think that is going to be in any way useful.

    The only way you can project vertical rows into horizontal columns is to PIVOT however what you end up with there is the values from one field become column headers and the values from another become your rows so you would have something like below:

                      **W1234**            **A7654**
    LOCATION COUNT      10                    23
    

    However in your case this would just make your grid view have one row and many columns, really for this to be usefull you need a third variable to group by vertically such as deptartment.

    If you simply want to have the amount of vertical space your data grid takes up on the page the you can just use 2 data grids and have the SP return 2 data sets, but then the data on matching rows in the 2 data grids will not relate to each other in any way.

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

Sidebar

Related Questions

ASP.NET 1.1 - I have a DataGrid on an ASPX page that is databound
For example, I have an ASP.NET form that is called by another aspx: string
I'm having a strange problem here... I have an ASP.NET 3.5 application that has
Do asp.net aspx views have tags that that work similar to the Ruby erb
We are developing an ASPX (.NET 2.0) page that includes a select list with
I have inherited an asp.net website to maintain when looking at the aspx page,
Just starting out in asp.net. Have just created a login.aspx page in my site
How do I create subdomains in ASP.NET? I have few links on my homepage(Home.aspx)
I have an ASPX page and on this page I have a control that
I'm trying to implement a DataGrid in ASP.NET, and want to achieve custom paging

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.