Click here to Skip to main content
12,692,105 members (26,497 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP ASP.NET Gridview Web
i have a gridview
in my grid view is this controls:
label ,button,image
i want ,when click on button of a cell of grid view
go to webform2 ,and show more info of that row(cell) of grid view
example :click on button(text="more info") and redirect to other page and view more info about that row of grid view that clicked.
plz give me a c# code
Posted 25-May-12 9:49am
Updated 25-May-12 11:11am
Technoses 26-May-12 1:12am
<asp:LinkButton style="width:70px;" ID="btnAct" Text='More Info' runat="server" OnClientClick='<%# "gomore(" + Eval("Id").ToString() + "); return false;" %>' />
Technoses 26-May-12 1:13am
sadegh_rusta 28-May-12 12:37pm
i want c#code
Technoses 29-May-12 12:26pm
this code is to be written on aspx page not in c#
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

you can use ASP:Template Field in Gridview
Which works fast then other process like
Not Necessary to call Row_DataBound event
which run for each for of grid
if grid has 1000 of rows then process goes slow..

How to use

 <asp:templatefield xmlns:asp="#unknown">
                <asp:linkbutton style="width:70px;" id="btnAct" text="More Info" runat="server" onclientclick="<%# "gomore(" + Eval("Id").ToString() + "); return false;" %>" />

and after grid you can add a javascript function i.e.

            function gomore(id)

try it.
if any problem then comment...

if your problem got solved then mark it as solution ..
sadegh_rusta 28-May-12 12:40pm
dont know
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

its just sample

<asp:GridView ID="gvUserdetails" runat="server" AutoGenerateColumns="False" OnRowCommand="gvUserdetails_RowCommand">
            <asp:TemplateField HeaderText="DELETE">
                    <asp:Button ID="btn1" runat="server" Text="Click for Details" CommandName="Show" CommandArgument='<%#Container.DataItemIndex %>' />
            <asp:TemplateField HeaderText="email">
            <asp:Label ID="lblemail" runat="server" Text='<%#Bind("Email") %>' />


and in .cs file code should be like this

protected void gvUserdetails_RowCommand(object sender, GridViewCommandEventArgs e)
   if (e.CommandName == "Delete")
    int index=Convert.ToInt32(e.CommandArgument);
    Response.Redirect("required page url");
sadegh_rusta 28-May-12 14:53pm
i do it
but in my project is error after click on button

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 26 May 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100