本文介绍了我在网格的网格视图中检索数据,如果我们单击该链接,则会有一个链接控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网格的网格视图中检索数据,如果单击该链接,我们将具有一个链接控件.
该链接显示有关此链接的全部信息,但是当我单击该链接数据时显示问题,但是在网格视图中有多个数据链接,我该如何在其上显示不同价值的信息,我做了这个任务,请看一下

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");
        con.Open();
        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();
        da.Fill(ds);


        //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;
        GridView1.DataBind();


显示数据但值固定,何时可以更改该链接上的值
用户单击过的链接,将显示有关此链接的值

请指导我该怎么办


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

推荐答案

<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.
} 


这篇关于我在网格的网格视图中检索数据,如果我们单击该链接,则会有一个链接控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 06:14