Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SelectedIndexChanged Event not firing when Select button Clicked

Posted on 2015-01-13
2
Medium Priority
?
394 Views
Last Modified: 2015-01-13
Good morning Experts!  Still trying to educate myself and having a hard time of it.  This is a ASP.NET Website Project (not a Web Application Project).  I have a GridView control on my content  page (within a master page).  When I click the "Select" button on a row I need to save the value in the "Id" column to a session variable so that I can use it elsewhere.  Unfortunately, the event that I thought would be best for this (SelectedIndexChanged) never fires when I click the "Select" button.  Any idea what I'm doing wrong?  Thanks!
    <asp:GridView ID="gvClientAccounts" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="dsClientAccounts" AutoGenerateColumns="False" OnSelectedIndexChanged="gvClientAccounts_SelectedIndexChanged">
        <Columns>
            <asp:TemplateField ShowHeader="True">
                <ItemTemplate>
                    <asp:HyperLink ID="lnkSelect" runat='server' NavigateUrl='<%# String.Format("~/Members/MyGroups.aspx?ClientID={0}", Eval("Id")) %>'>Select</asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="ClientName" HeaderText="Client Name" />
        </Columns>
    </asp:GridView><br />

Open in new window


    protected void gvClientAccounts_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["ClientID"] = gvClientAccounts.SelectedRow.Cells[0].Text;
    }

Open in new window


    <asp:GridView ID="gvClientAccounts" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="dsClientAccounts" AutoGenerateColumns="False" OnSelectedIndexChanged="gvClientAccounts_SelectedIndexChanged">
        <Columns>
            <asp:TemplateField ShowHeader="True">
                <ItemTemplate>
                    <asp:HyperLink ID="lnkSelect" runat='server' NavigateUrl='<%# String.Format("~/Members/MyGroups.aspx?ClientID={0}", Eval("Id")) %>'>Select</asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="ClientName" HeaderText="Client Name" />
        </Columns>
    </asp:GridView><br />

Open in new window

0
Comment
Question by:penlandt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Michael Fowler earned 2000 total points
ID: 40547901
I cannot see a select button for the control.
Add an auto generated select button and when selected this will fire your event


AutoGenerateSelectButton="True"
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.autogenerateselectbutton(v=vs.110).aspx

<asp:GridView ID="gvClientAccounts" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="dsClientAccounts" AutoGenerateColumns="False" AutoGenerateSelectButton="True" OnSelectedIndexChanged="gvClientAccounts_SelectedIndexChanged">

Open in new window

0
 
LVL 1

Author Closing Comment

by:penlandt
ID: 40547987
Of course!  I'm overthinking this.  Did what you said and it works perfectly.  Thank you.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question