Click here to Skip to main content
16,004,887 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Gridview filtering Pin
GreenGiant8312-Oct-07 5:27
GreenGiant8312-Oct-07 5:27 
GeneralRe: Gridview filtering Pin
N a v a n e e t h12-Oct-07 5:29
N a v a n e e t h12-Oct-07 5:29 
GeneralRe: Gridview filtering Pin
GreenGiant8312-Oct-07 5:30
GreenGiant8312-Oct-07 5:30 
GeneralRe: Gridview filtering Pin
N a v a n e e t h12-Oct-07 5:37
N a v a n e e t h12-Oct-07 5:37 
GeneralRe: Gridview filtering Pin
GreenGiant8312-Oct-07 5:39
GreenGiant8312-Oct-07 5:39 
GeneralRe: Gridview filtering Pin
N a v a n e e t h12-Oct-07 5:44
N a v a n e e t h12-Oct-07 5:44 
GeneralRe: Gridview filtering Pin
GreenGiant8312-Oct-07 5:47
GreenGiant8312-Oct-07 5:47 
AnswerRe: Gridview filtering Pin
GreenGiant8312-Oct-07 6:02
GreenGiant8312-Oct-07 6:02 
I dont know if it will help but here is my current approach. I have link button's added to the control to allow the user to select the filter criteria. When that button is clicked it gets the gets a DataSourceView using the GetData() command, which I then run a Select command against. Which generates an async call to my function FilterDataDSVSelectCallback. This method accepts an IEnumerable object as an argument. I then look at the data in this argument and remove the rows I dont need. And here is the party that I think I am doing wrong. Then I remove any DataSourceID and tell the control that its new datasource is the modified IEnumerable that I got in as an argument and call DataBind. For what it is worth this works great....once. Any subsequent calls to filter, and the passed in IEnumerable object is null.

<br />
void btnFilter_Click(object sender, EventArgs e)<br />
        {<br />
            LinkButton btnFilter = (LinkButton)sender;<br />
            FilterFieldName = btnFilter.CommandName;<br />
            FilterFieldValue = btnFilter.CommandArgument;<br />
<br />
            DataSourceView dsv = GetData();<br />
            DataSourceSelectArguments args = new DataSourceSelectArguments();<br />
            dsv.Select(args, new DataSourceViewSelectCallback(FilterDataDSVSelectCallback));<br />
        }<br />
<br />
        void FilterDataDSVSelectCallback(IEnumerable e)<br />
        {<br />
            if (e == null) return;<br />
<br />
            DataView dv = (DataView)e;<br />
            DataTable dt = dv.Table;<br />
<br />
            List<DataRow> RemoveList = new List<DataRow>();<br />
            for(int i=0;i<dt.Rows.Count;i++)<br />
            {<br />
                if (!object.Equals(dt.Rows[i][FilterFieldName], FilterFieldValue))<br />
                {<br />
                    RemoveList.Add(dt.Rows[i]);<br />
                }<br />
            }<br />
            foreach (DataRow row in RemoveList)<br />
            {<br />
                dt.Rows.Remove(row);<br />
            }<br />
            <br />
            string prevDataSourceID = DataSourceID;<br />
            DataSourceID = null;<br />
            DataSource = dt;<br />
            DataBind();<br />
        }

GeneralRe: Gridview filtering Pin
GreenGiant8312-Oct-07 6:11
GreenGiant8312-Oct-07 6:11 
QuestionFormView EditItemTemplate Pin
pradeep kumarappagari12-Oct-07 3:30
pradeep kumarappagari12-Oct-07 3:30 
QuestionFreezing html Table Pin
varshavmane12-Oct-07 2:56
varshavmane12-Oct-07 2:56 
GeneralRe: Freezing html Table Pin
Anand Suresh13-Jan-08 22:12
Anand Suresh13-Jan-08 22:12 
Questionall, Pin
ajay5888612-Oct-07 2:01
ajay5888612-Oct-07 2:01 
AnswerRe: all, Pin
N a v a n e e t h12-Oct-07 5:11
N a v a n e e t h12-Oct-07 5:11 
QuestionRegarding Deployment of application in Asp.net 2.0 Pin
Aavesh Agarwal12-Oct-07 2:01
Aavesh Agarwal12-Oct-07 2:01 
AnswerRe: Regarding Deployment of application in Asp.net 2.0 Pin
kubben12-Oct-07 2:18
kubben12-Oct-07 2:18 
AnswerRe: Regarding Deployment of application in Asp.net 2.0 Pin
Sandeep Kumar12-Oct-07 2:20
Sandeep Kumar12-Oct-07 2:20 
AnswerRe: Regarding Deployment of application in Asp.net 2.0 Pin
Dave Kreskowiak12-Oct-07 4:18
mveDave Kreskowiak12-Oct-07 4:18 
QuestionMessageBox Pin
M_Menon12-Oct-07 1:54
M_Menon12-Oct-07 1:54 
AnswerRe: MessageBox Pin
kubben12-Oct-07 2:00
kubben12-Oct-07 2:00 
GeneralRe: MessageBox Pin
M_Menon12-Oct-07 2:37
M_Menon12-Oct-07 2:37 
GeneralRe: MessageBox Pin
kubben12-Oct-07 2:39
kubben12-Oct-07 2:39 
GeneralRe: MessageBox Pin
M_Menon12-Oct-07 3:07
M_Menon12-Oct-07 3:07 
GeneralRe: MessageBox Pin
kubben12-Oct-07 3:14
kubben12-Oct-07 3:14 
GeneralRe: MessageBox Pin
M_Menon12-Oct-07 3:17
M_Menon12-Oct-07 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.