Click here to Skip to main content
13,051,809 members (47,486 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I retrieve data in grid view in grid we have a link control if we click on that link
the link show total information on regarding this link but i have a problem when i click on that link data is show but in grid view multiple data link is there how can i show information different different value on it i did so task please have a look
SqlConnection con;
        con = new SqlConnection("Data Source=RESTON-PC;Initial Catalog=Easy2Connect;Integrated Security=True");
        string s = "Select AdTitle,DescriptionofAd,TeachingSubject,Preferlocation,Classwise,Address,MobileNo,Logo  from HomeTuitionInformation where ADType = 'Offer'";
        SqlCommand cmd = new SqlCommand(s, con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();

        //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        //    TextBox1.Text += ds.Tables[0].Rows[i]["AdTitle"].ToString() + "  , ";
       // string i = ds.Tables[0].Rows[0]["AdTitle"].ToString();
      //  string  var1 = Convert.ToString( ds.Tables[0].Rows[0].ToString()); //ds.Tables[0].Rows[0]["AdTitle"]);
        Session["Ad"] = 
        GridView1.DataSource = ds;

data is show but value is fix when how can i change the value on that link
what ever link is click by user the value is show regarding this link

please guide me what should i do
Posted 7-Oct-12 21:40pm
Updated 7-Oct-12 22:14pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Use the command name and command argument object avail into the link button and give the value some identity into the commnad name or argument.

And access the value into the on click event method, Use that value to redirect or fetch the data for that identity to display.

Hope this will help you.

Use below code.

<asp:LinkButton Id="linkButtonABC" runat="server" CommandName="Display" Text="Display" CommandArgument='<%# Eval("id") %>' />

and then in row command method add below code.

protected void RowCommand( object sender, GridViewCommandEventArgs e ) 
    int rowIndex = Convert.ToInt32( e.CommandArgument );  
    //Here you can write your code to display.
M@anish 8-Oct-12 4:54am
i know but i dont know how to do this
Mohd. Mukhtar 8-Oct-12 5:01am
For this you need to bind CommandName value in HTML.
For more assistant you should copy your gridview HTML code here.

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
Web01 | 2.8.170713.1 | Last Updated 8 Oct 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