Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

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()
Avatar of Ramkisan Jagtap
Ramkisan Jagtap
Flag of Finland image

NSN.Tables(0).DefaultView.Sort("YourFiledName ASC")
Avatar of Victor  Charles

ASKER

Thanks!
Please accept the answer if you found the useful!!! :)
I will test it tomorrow, than accept is as the solution. Thanks again.
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.
Avatar of Nasir Razzaq
What happens if you break the line to

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

 C1ANSN.DataSource = NSNType.Tables(0).DefaultView
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()
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.
@ramkisan

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

@vchales

Missed http:#a38024782 ?
Hi,

I will try it tomorrow and get back to yu.

Thanks.

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

Check: http:#a38010338
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.
ASKER CERTIFIED SOLUTION
Avatar of Ramkisan Jagtap
Ramkisan Jagtap
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks! It worked.