I need to get selected index value from the dropdownlist and sort it on the GridView.

The code above can only sort by column.

Anybody has any idea how to add the column with the selectedValue into the Sort?

dv.RowFilter = "NOID = '" + ddl.SelectedValue.ToString() + "'";
dv.Sort = "NOID = '" + ddl.SelectedItem + "'" + " " + "ASC";

i do not want this -

dv.Sort = "ID ASC";

Recommended Answers

All 2 Replies

hi there, just missed out some stuff, resolved.

Sort property requires a column/field name on which sorting can be done.

dv.Sort = "NOID"; // NOID is a field/column name
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.