gridview question and c#

Saroj13 used Ask the Experts™

I have gridview.  I am displaying ID, Title, Text in columns in gridview. On page load, text column is not displaying anything.

How to achieve if click on Title, will display the corresponding text in Text column in gridview.

Please see the picture and code:

<head runat="server">
      <script src="../scripts/jquery-1.6.1.js" type="text/javascript"></script>  
      <script src="../scripts/jquery.tablednd_0_5.js" type="text/javascript"></script>  



             -webkit-user-select: none;  

             -khtml-user-select: none;  

             -moz-user-select: none;  

             -o-user-select: none;  

             user-select: none;  

             cursor: move;  




             background-color: Lime;  


            height: 8px;
            height: 2px;

            height: 24px;
            height: 1px;


     <script type="text/javascript">  

var strorder;  

 $(document).ready(function() {



     onDrop: function(table, row) {  



              type: "POST",

              url: "ScriptOrder.aspx/GridViewReorders",

              data: '{"Reorder":"' + strorder + '"}',  

              contentType: "application/json; charset=utf-8",  

              dataType: "json",  

              async: true,  

              cache: false,  

              success: function (msg) {  

              alert("Successfully Save ReOrder");  








 function  reorder()  



     var totalid = $('#ScriptsGridView tr td input').length;  

     for(var i=0;i<totalid;i++)  


         strorder = strorder + $('#ScriptsGridView tr td input')[i].getAttribute("value") + "|";  




      <form id="frmOrderScript" runat="server">
                      <td class="style7">
            <td class="style3">
                <asp:GridView ID="ScriptsGridView" runat="server" 
                    HeaderStyle-CssClass="nodrag nodrop" AutoGenerateColumns="False" GridLines="Both"
                    ShowHeader="True" Width="100%" 
                    style="position: relative; top: -40px; left: 275px; height: 2px;" 
                    onrowdatabound="ScriptsGridView_RowDataBound" >
                      <asp:TemplateField ItemStyle-CssClass="noselect" HeaderText="ID">  


         <asp:Label ID="lblID" runat="server" Text='<%# Bind("ScriptID") %>'></asp:Label>  

        <asp:HiddenField ID="hdnid" runat="server" Visible="true" Value='<%# Bind("ScriptID") %>' />  



         <asp:TemplateField ItemStyle-CssClass="noselect" HeaderText="Script Name">  


          <asp:Label ID="lblName" runat="server" Text='<%# Bind("Title") %>'></asp:Label>  



      <asp:TemplateField HeaderText="Display Order" ItemStyle-CssClass="noselect">  


           <asp:Label ID="lblOrder" runat="server" Text='<%# Bind("DisplayOrder") %>'>  




          <asp:TemplateField HeaderText="Text" ItemStyle-CssClass="noselect"   >  
         <RowStyle BackColor="#ffffff" />
                    <AlternatingRowStyle BackColor="#ffffff" />

           <asp:Label ID="lbText" runat="server" Text='<%# Bind("Text") %>'>  





Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Kaushal AroraTechnical Analyst

You can achieve this using the SelectedIndexChanging Event of the gridview. When you will click the Title Column, in the event you will get the RowIndex of the title you clicked and based on that you can fetch the text you want to show and display that on the area defined.

To display the text in area you need to first find the label placed there in the control using FindControl method available.

For reference check out this link for full Gridview events knowledge:

Hope it helps you.
You can do it from client side also... as there is no communication with server for doing this functionality:

Here is your solution:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial