GridView Control Click

Hi,

I have a Gridview control bound to data returned from a database.  I want to be able to click on one of the Gridview rows to bring up more information.  Ideally, using some javascript to slide down the further information.  But if that's not possible/too complicated then taking the user to another form and passing the record ID would be fine.

Anyone able to assist?

Cheers...

John
johnnyc82Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alfred A.Commented:
0
Alfred A.Commented:
0
drypzCommented:
Hi something like this

.aspx

        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="grid"
            DataKeyNames="ID" OnRowCommand="GrieView1_RowCommand" >
            <Columns>
                <asp:TemplateField HeaderText="Name">
                    <ItemTemplate>
                        <asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Address">
                    <ItemTemplate>
                        <asp:Label ID="lblAddress" runat="server" Text='<%#Eval("Address")%>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="EDITRECORD"
                            CommandArgument='<%#Container.DataItemIndex %>' />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>


.CS (Codebehind)

    protected void gridCategory_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "EDITRECORD")
        {
            //you can get the ID of the row like this
            int index = Convert.ToInt32(e.CommandArgument);
            GridViewRow gridRow = GridView1.Rows[index];

            int id = (int)GridView1.DataKeys[index]["ID"];

            Response.Write(id.ToString());
        }
    }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.