Page 1 of 1

Gridview data selection based on Checbox

Posted: Wed Jun 09, 2010 6:32 pm
by Neofriend
Basically, what I'd like here is, if the checbox is selected on the page. The gridview should show only the records that has a specific username (his username). Otherwise, it should show all, as it shows now.

Any idea? - I have an idea, but am confused a bit with how to not display that column in gridview and still use it for such filtering.

Re: Gridview data selection based on Checbox

Posted: Fri Jun 11, 2010 5:05 am
by Neo
I'm sure you can hide a column but still use it for filtering. My memory is not so good with grids as I didn't use them for years.

Re: Gridview data selection based on Checbox

Posted: Sat Jun 12, 2010 5:46 pm
by Neofriend
Alright, thank you. Say, I've half-handled it though need a little guidance with something else now.

I have a dropdown, like this

Code: Select all

   
                 <asp:DropDownList ID="DropDownList8" runat="server" AutoPostBack="True">
                        <asp:ListItem Value="%">No</asp:ListItem>
                        <asp:ListItem Value="">Yes</asp:ListItem>
                    </asp:DropDownList>

and want the Yes listitem value to be catched from code-behind file of public string variable namely, yesUserid.

What I tried is,

Code: Select all

   
                 <asp:DropDownList ID="DropDownList8" runat="server" AutoPostBack="True">
                        <asp:ListItem Value="%">No</asp:ListItem>
                        <asp:ListItem Value="<%=yesUserid %>">Yes</asp:ListItem>
                    </asp:DropDownList>

but it doesn't work, though it used to work with javascript when transferring the value to vars, but not here.

What to do? the second question is pretty complicated so am better off not asking it now and doing my best to solve that out.

But just to get a hint, is it possible to change the selectCommand of a datasource?, when some specific item of a dropdown is selected? I believe yes, using SelectedIndexChanged event and checking if its value is equal to a specific value, then accessing the sqldatasourcename.SelectCommand = .... am i making any sense here? hope I do...