Avatar of Saroj13
 asked on

gridview question asp.net and c#


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


Avatar of undefined
Last Comment

8/22/2022 - Mon
Kaushal Arora

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.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.