troubleshooting Question

gridview question asp.net and c#

Avatar of Saroj13
Saroj13 asked on
C#ASP.NET
2 Comments1 Solution618 ViewsLast Modified:
Hi,

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">
    <title></title>
  
      <script src="../scripts/jquery-1.6.1.js" type="text/javascript"></script>  
      <script src="../scripts/jquery.tablednd_0_5.js" type="text/javascript"></script>  
    <style>  

        .noselect  

         {  

             -webkit-user-select: none;  

             -khtml-user-select: none;  

             -moz-user-select: none;  

             -o-user-select: none;  

             user-select: none;  

             cursor: move;  

         }  

         .tDnD_whileDrag  

         {  

             background-color: Lime;  

         }  

        .style3
        {
            height: 8px;
        }
        .style5
        {
            height: 2px;
        }

        .style6
        {
            height: 24px;
        }
        .style7
        {
            height: 1px;
        }

        </style>  

     <script type="text/javascript">  

var strorder;  

 $(document).ready(function() {

     $('#ScriptsGridView').tableDnD(  

 {  

     onDrop: function(table, row) {  

     reorder();  

     $.ajax({  

              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()  

 {   

     strorder="";

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

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

     {

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

     }  

 }  

     </script>  

  
</head>
<body>
      <form id="frmOrderScript" runat="server">
         <table>
           <tr>
                      <td class="style7">
                            </td></tr>
              <tr>
            <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" >
                   
                    <Columns>
                      <asp:TemplateField ItemStyle-CssClass="noselect" HeaderText="ID">  

       <ItemTemplate>  

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

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

       </ItemTemplate>  

      </asp:TemplateField>  

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

        <ItemTemplate>  

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

          </ItemTemplate>  

         </asp:TemplateField>  

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

         <ItemTemplate>  

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

 </asp:Label>  

           </ItemTemplate>  

         </asp:TemplateField>  

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

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

 </asp:Label>  

           </ItemTemplate>  

         </asp:TemplateField>  

             
                    </Columns>
                </asp:GridView>
            </td>
        </tr>
    </table>
gridview.doc
ASKER CERTIFIED SOLUTION
Mrunal

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros