Help with sorting chechbox list control

vcharles
vcharles used Ask the Experts™
on
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()
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Ramkisan JagtapLead Developer

Commented:
NSN.Tables(0).DefaultView.Sort("YourFiledName ASC")

Author

Commented:
Thanks!
Ramkisan JagtapLead Developer

Commented:
Please accept the answer if you found the useful!!! :)
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Author

Commented:
I will test it tomorrow, than accept is as the solution. Thanks again.

Author

Commented:
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.
Most Valuable Expert 2012
Top Expert 2014

Commented:
What happens if you break the line to

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

 C1ANSN.DataSource = NSNType.Tables(0).DefaultView
Ramkisan JagtapLead Developer

Commented:
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()

Author

Commented:
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.
Most Valuable Expert 2012
Top Expert 2014

Commented:
@ramkisan

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

@vchales

Missed http:#a38024782 ?

Author

Commented:
Hi,

I will try it tomorrow and get back to yu.

Thanks.

V,
Ramkisan JagtapLead Developer

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

Check: http:#a38010338

Author

Commented:
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.
Lead Developer
Commented:
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()


Please try this way .

Author

Commented:
Thanks! It worked.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial