Datatable Column Filter

Posted by Laghaterohan under jQuery on 4/29/2013 | Points: 10 | Views : 2306 | Status : [Member] | Replies : 3
Hello,
I have a gridview with Bound fields..and I need to apply column filter plugin to it in order to enable Multiple column filter.
However, inorder for this plugin to work we need to add an additional HTML code : (Refer below link : )
http://jquery-datatables-column-filter.googlecode.com/svn/trunk/default.html

I require help to implement this additional HTML Code. May I know how can I add this to my exisiting gridview , either in .aspx page or through C# code so that my column filter works as expected?

Pl. Help.

Best Regards,
Rohan Laghate



Responses

Posted by: Jitendrasoft09 on: 4/29/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi,
You have to create your table or new row and you can add new row or table with jquery or javascript into existing gridview as below link is mentioned.
http://stackoverflow.com/questions/2639162/c-sharp-html-tags-inside-gridview

Jitendra Kumar
If my post helps you, plz mark as an answer.

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saclines on: 8/22/2014 [Member] Starter | Points: 25

Up
0
Down
Use LINQ
http://www.dotnetlines.com/forum/tabid/86/forumid/2/threadid/277/scope/posts/Default.aspx

Sachin N. S.

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenhcl on: 9/3/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

As per your thread you are looking for Gridview column wise filtering option right.?

Then you need to set the AllowSorting property of Gridview to true and set the SortExpression property for each and every field. and then wrote code for the same onSorting event of Gridview.

Refer below sample.

<asp:TemplateField HeaderText="Contract Caption" SortExpression="Contract_Caption">
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>


and in code behind wrote below lines of code.

protected void gvContract_Admin_Sorting(object sender, GridViewSortEventArgs e)
{
try
{
if (ViewState["ds"] != null)
ds = ViewState["ds"] as DataSet;

SortDirection dir = SortDirection.Ascending;

if (ViewState["dir"] != null)
dir = (SortDirection)ViewState["dir"];
string sortingDirection = string.Empty;
if (dir == SortDirection.Ascending)
{
dir = SortDirection.Descending;
sortingDirection = "Desc";
}
else
{
dir = SortDirection.Ascending;
sortingDirection = "Asc";
}
ViewState["dir"] = dir;
DataView dv = ds.Tables[0].DefaultView;
dv.Sort = e.SortExpression + " " + sortingDirection;

gvContract_Admin.DataSource = dv;
gvContract_Admin.DataBind();
}
catch (Exception ex)
{
throw ex;
}

}


Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response