Avatar of vcharles
vcharles
 asked on

Help with sorting chechbox list control

How do you sort a checkbox list web control?

Dim NSN As New DataSet
        NSN.ReadXml(Server.MapPath("~/App_Data/NSN.xml"))
        C1ANSN.DataSource = NSN.Tables(0)
        C1ANSN.DataMember = "NSN"
        C1ANSN.DataTextField = "NSN"
        C1ANSN.DataValueField = "NSN_ID"
        C1ANSN.Sort?????????
        C1ANSN.DataBind()
ASP.NET.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
vcharles

8/22/2022 - Mon
Ramkisan Jagtap

NSN.Tables(0).DefaultView.Sort("YourFiledName ASC")
vcharles

ASKER
Thanks!
Ramkisan Jagtap

Please accept the answer if you found the useful!!! :)
Your help has saved me hundreds of hours of internet surfing.
fblack61
vcharles

ASKER
I will test it tomorrow, than accept is as the solution. Thanks again.
vcharles

ASKER
Hi,

When I tried the code below:

    Dim NSNType As New DataSet
        NSNType.ReadXml(Server.MapPath("~/App_Data/NSNType.xml"))                        C1ANSN.DataSource = NSNType.Tables(0).DefaultView.Sort("NSN ASC")
        C1ANSN.DataMember = "NSN"
        C1ANSN.DataTextField = "NSN"
        C1ANSN.DataValueField = "NSN_ID"
        C1ANSN.DataBind()
I received the following error:

Conversion from string "NSN ASC" to type 'Integer' is not valid.

How do I fix this error?

Thanks,

V.
Nasir Razzaq

What happens if you break the line to

 NSNType.Tables(0).DefaultView.Sort("NSN ASC")

 C1ANSN.DataSource = NSNType.Tables(0).DefaultView
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Ramkisan Jagtap

Try as below:
   
NSNType.ReadXml(Server.MapPath("~/App_Data/NSNType.xml"))      
NSNType.Tables[0].DefaultView.Sort = "NSN ASC"
C1ANSN.DataSource = NSNType.Tables(0).DefaultView
C1ANSN.DataMember = "NSN"
C1ANSN.DataTextField = "NSN"
C1ANSN.DataValueField = "NSN_ID"
C1ANSN.DataBind()
vcharles

ASKER
Hi,

I am getting the following error:

Property access must assign to the property or use its value.

on line:

NSNType.Tables[0].DefaultView.Sort = "NSN ASC"

How do I fix this error?

Thanks,

V.
Nasir Razzaq

@ramkisan

The idea is to not repeat suggestions of other experts. That too with syntax errors. [] is used in C#.

@vchales

Missed http:#a38024782 ?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
vcharles

ASKER
Hi,

I will try it tomorrow and get back to yu.

Thanks.

V,
Ramkisan Jagtap

@CodeCruiser:
I have already suggested what you have in Comment http:#a38024782

Check: http:#a38010338
vcharles

ASKER
Hi,

When I try:

NSNType.Tables(0).DefaultView.Sort("NSN ASC")

 C1ANSN.DataSource = NSNType.Tables(0).DefaultView

I receive the following error:

Property access must assign to the property or use its value.

On Line:

NSNType.Tables(0).DefaultView.Sort("NSN ASC")

How do I fix this error?

Thanks,

V.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
Ramkisan Jagtap

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
vcharles

ASKER
Thanks! It worked.