Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi I am working on RadGrid Controls with Template Fields and the grid details are working but the records are showing like a sentence,No rows or columns are inside the grid and the details are showing like a sentence.

What I have tried:

ASP.NET
<pre><div>
            <telerik:RadGrid ID="gvDetails" CommandItemDisplay ="Top" margin-top="-46px" Height="500px" runat="server"
                 EnableAjaxSkinRendering="true"
                OnPageIndexChanging="OnPaging"
                AutoGenerateColumns="False" HeaderStyle-BackColor="#61A6F8"
                ShowFooter="True" HeaderStyle-Font-Bold="true" HeaderStyle-ForeColor="White"
                CellPadding="10" CellSpacing="0" PageSize="5" GridLines="None" Skin="Forest"
                OnUpdateCommand="gvDetails_UpdateCommand"
                
                OnItemCommand="gvDetails_ItemCommand"
                OnNeedDataSource="gvDetails_NeedDataSource"
                OnItemDeleted="gvDetails_ItemDeleted">

                
                 <MasterTableView EditMode="InPlace" DataKeyNames="EmpId,EmpName" AutoGenerateColumns="false"> 
                    <Columns>
                        <telerik:GridTemplateColumn HeaderText="EmployeeID" ShowFilterIcon="false" ShowSortIcon="true"> 
                                    <ItemTemplate>
                            <asp:Label ID="lblempid" runat="server" class="clsempid"
                                Text='<%# Eval("EmpId")%>'></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtempid" 
                                MaxLength="5" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvempid"  runat="server" ControlToValidate="txtempid" Text="*" ValidationGroup="validaiton" />
                        </FooterTemplate>
                                </telerik:GridTemplateColumn> 



ASP.NET
<pre><telerik:GridTemplateColumn HeaderText="EmployeeName" ShowFilterIcon="false"> 
                                    <EditItemTemplate>
                            <asp:TextBox ID="txtempname" runat="server"   Text='<%#Eval("EmpName") %>' />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblempname" runat="server" class="clsempid1" Text='<%#Eval("EmpName") %>' />
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtempname1" runat="server"  AutoPostBack="false" onkeypress="hidedialog(this)" />
                            <asp:RequiredFieldValidator ID="rfvempname" runat="server" ControlToValidate="txtempname1" Text="*" ValidationGroup="validaiton" />
                        </FooterTemplate>
                                </telerik:GridTemplateColumn> 



C#
protected void gvDetails_NeedDataSource(object source, GridNeedDataSourceEventArgs e)

        {
          DataTable  dtTable = new DataTable();
            //Open the SqlConnection  
            cn.Open();
            try
            {
                //Select Query to populate the RadGrid with data from table Customers.  
                
                SqlCommand cmd = new SqlCommand("gvempdetails", cn);
                cmd.Parameters.AddWithValue("@Action", "SELECT");
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                gvDetails.DataSource = dtTable;
              
                
            }
            finally
            {
                //Close the SqlConnection  
                cn.Close();
            }  
        
        }
Posted

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