Gridview data selection based on Checbox

Post Reply
Neofriend
Captain
Captain
Posts: 103
Joined: Wed Dec 23, 2009 3:37 pm
Location: Pakistan

Gridview data selection based on Checbox

Post by Neofriend » Wed Jun 09, 2010 6:32 pm

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.
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Gridview data selection based on Checbox

Post by Neo » Fri Jun 11, 2010 5:05 am

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.
Neofriend
Captain
Captain
Posts: 103
Joined: Wed Dec 23, 2009 3:37 pm
Location: Pakistan

Re: Gridview data selection based on Checbox

Post by Neofriend » Sat Jun 12, 2010 5:46 pm

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...
Post Reply

Return to “ASP & ASP.Net”