I am using the sorting function for the gridview and getting the above error
My sorting function is
protected void gvUserMaster_Sorting(object sender, GridViewSortEventArgs e)
{
UserMasterClass cs = new UserMasterClass();
ResultClass objres = cs.fn_GetUserMasterList();
if (objres.bStatus)
{
eslist<UserMasterClass> OBJLIST = objres.objData as eslist<UserMasterClass>;
if (OBJLIST.Count > 0)
{
DataTableConverter<UserMasterClass> dt = new DataTableConverter<UserMasterClass>();
dt.GetDataTable(OBJLIST);
if (dt != null)
{
DataView dataView = new DataView(dt);
dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection);
gvUserMaster.DataSource = dataView;
gvUserMaster.DataBind();
}
}
}
}
I am getting the error on this line DataView dataView = new DataView(dt);
Thanks,
Yes, you’re trying to pass a
DataTableConverter<UserMasterClass>into a constructor which expects aDataTable. You’re also callingGetDataTableand ignoring the result, just beforehand. Perhaps you meant:(As an aside, your naming conventions are all over the place – I’d strongly advise you to follow the normal .NET conventions.)