Click here to Skip to main content
16,019,983 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have populated certain rows in gridview control through code behind. Each row has a linkbutton.

When i click that link button, i need to get the rows/cells information and make the information always visible on the screen .plz help
Posted
Comments
Sunasara Imdadhusen 22-Sep-11 8:09am    
You may create a DIV with always visible. whenever you clicked on link you need to set content of clicked row in DIV.

1 solution

Hi,

I tried some code for your requirement check this once

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script language ="javascript" >
        function f1(tid) {
            document.getElementById("residv").innerHTML = tid;
            document.getElementById("residv").style.display = '';
            return false;
        }
 </script>
</head>
<body >
    <form id="form1" runat="server">
    <div>
        <asp:datalist id="DataList1" runat="server" xmlns:asp="#unknown">
            onitemcommand="DataList1_ItemCommand" 
            onitemdatabound="DataList1_ItemDataBound"  >
        <HeaderTemplate >  <table>
        </HeaderTemplate>
        <itemtemplate>
       
      
          <tr>
            <td>
              
            </td>
            <td>
                <asp:linkbutton id="LinkButton1" runat="server" commandname="save" commandargument="2">save</asp:linkbutton>
            </td>
          </tr>
        
        </itemtemplate>
        <footertemplate>
         </footertemplate></table>
        
        </asp:datalist>
        <div id="residv" style=" position:fixed; bottom :0px; right :0px; display :none; color:Red ;"></div>
    </div>
    </form>
</body>
</html>


And code behind file contains following code

C#
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<string> g = new List<string>();
            g.Add("hjghj");
            g.Add("hjghj");
            g.Add("hjghj");
            g.Add("hjghj");
            g.Add("hjghj");
            g.Add("hjghj");
            g.Add("hjghj");
            DataList1.DataSource = g;
            DataList1.DataBind();
        }
    }


    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "save")
        {

        }
    }
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
         
            LinkButton lblqid = (LinkButton)e.Item.FindControl("LinkButton1");
            string str="data retrieved from database "+e.Item.ItemIndex ;
            lblqid.OnClientClick = "return f1('"+str +"')";
        }
    }
</string></string>


In the above code you can retrieve data from database based on that item

If you use Jquery it is very simple than this


I hope you understood what I did,you get idea on what you can do for your requirement


All the Best.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900