C# Asp控件不工作

C# Asp控件不工作,c#,asp.net,.net,telerik,C#,Asp.net,.net,Telerik,我正在尝试使用Telerik列表视图。我刚刚添加了一个SqlDataSource,我想在服务器端给出select命令。但是当我想在.cs文件中访问它时,SqlDataSource1是不可访问的,即使没有显示任何控件。我在尝试Label1时添加了一个标签。Label1文本在.cs文件中不可访问 <%@ Page Title="" Language="C#" MasterPageFile="~/PortalSite.Master" AutoEventWireup="true" CodeBehi

我正在尝试使用Telerik列表视图。我刚刚添加了一个SqlDataSource,我想在服务器端给出select命令。但是当我想在.cs文件中访问它时,SqlDataSource1是不可访问的,即使没有显示任何控件。我在尝试Label1时添加了一个标签。Label1文本在.cs文件中不可访问

<%@ Page Title="" Language="C#" MasterPageFile="~/PortalSite.Master" AutoEventWireup="true" CodeBehind="category.aspx.cs" Inherits="NoidaPortal.category" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<style type="text/css">
    .rdpWrap .RadInput, .rdpWrap .rdpPagerButton, .rdpWrap .rdpPagerLabel
    {
        float: left;
    }
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:SqlDataSource ID="SqlDataSource2" runat="server"></asp:SqlDataSource>

<div>
    <!-- content start -->
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script type="text/javascript">
            function RequestStart(sender, eventArgs) {
                //disable ajax on update/insert operation to upload the image
                if ((eventArgs.get_eventTarget().indexOf("Update") > -1) || (eventArgs.get_eventTarget().indexOf("PerformInsert") > -1)) {
                    eventArgs.set_enableAjax(false);
                }
            }
        </script>

    </telerik:RadCodeBlock>
    <table>
        <tr>
            <td>
                <asp:Panel ID="ListViewPanel1" runat="server">
                    <telerik:RadListView ID="RadListView1" DataSourceID="SqlDataSource1" runat="server"
                        ItemPlaceholderID="CustomersContainer" DataKeyNames="ArchitectId" AllowPaging="True"
                        >
                        <LayoutTemplate>
                            <!-- Set the id of the wrapping container to match the CLIENT ID of the RadListView control to display the ajax loading panel
                     In case the listview is embedded in another server control, you will need to append the id of that server control -->
                            <fieldset id="FiledSet1" style="width:435px;">
                                <legend>Customers</legend>
                                <table cellpadding="0" cellspacing="0" width="100%">
                                    <tr>
                                        <td>
                                            <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
                                                PageSize="5" Width="435px">
                                                <Fields>
                                                    <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                                                    <telerik:RadDataPagerButtonField FieldType="Numeric" PageButtonCount="6" />
                                                    <telerik:RadDataPagerButtonField FieldType="NextLast" />
                                                    <telerik:RadDataPagerPageSizeField PageSizeText="Page size: " />



                                                </Fields>
                                            </telerik:RadDataPager>
                                        </td>
                                    </tr>
                                </table>
                                <asp:PlaceHolder ID="CustomersContainer" runat="server" />
                                <div style="clear: both" />
                                <br />
                                <br />
                                <table style="width: 100%;">
                                    <tr>
                                        <%--<td style="width: 25%;">
                                            <asp:Button ID="btnInitInsert" runat="server" Text="Insert Customer" OnClick="btnInitInsert_Click" />
                                        </td>--%>
                                        <td style="text-align:center; width: 75%;">
                                            <asp:Label ID="lblSort1" runat="server" Text="Sort by:" Style="padding-right: 5px;" />
                                            <telerik:RadComboBox ID="ddListSort" runat="server" AutoPostBack="true">
                                                <Items>
                                                    <telerik:RadComboBoxItem Text="-Select field to sort-" Value="" />
                                                    <telerik:RadComboBoxItem Text="Company name" Value="ArchitectName" />
                                                    <telerik:RadComboBoxItem Text="Sector" Value="Sector" />

                                                </Items>
                                            </telerik:RadComboBox>
                                        </td>
                                    </tr>
                                </table>
                                </div>
                            </fieldset>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <!--The widths/heights of the fieldset/outer tables in the item/edit/insert templates should match to avoid wrapping or visual discrepancies
                         in the tiles layout-->
                            <fieldset style="float: left; width: 410px; height: 215px; margin-top:10PX;">
                                <legend style="font-weight:bold">
                                    <%# Eval("ArchitectName")%></legend>
                                <table cellpadding="0" cellspacing="0" style="height: 100%;" width="370px">
                                    <tr>
                                        <td>
                                            <table cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td>
                                                        <table cellpadding="0" cellspacing="0">
                                                            <tr>
                                                                <td style="font-weight:bold; width:25%">
                                                                    Address:
                                                                </td>
                                                                <td style="width:auto; width:75%;">
                                                                    <%#Eval("ArchitectAddress")%>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="width:25%; font-weight:">
                                                                    City:
                                                                </td>
                                                                <td>
                                                                    <%# Eval("Contact1")%>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="font-weight:bold">
                                                                    Country:
                                                                </td>
                                                                <td>
                                                                    <%# Eval("Contact2")%>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="font-weight:bold">
                                                                    Phone:
                                                                </td>
                                                                <td>
                                                                    <%#Eval("Email_Id")%>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td style="font-weight:bold">
                                                                    Website:
                                                                </td>
                                                                <td>
                                                                    <%#Eval("Website")%>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                 </table>
                            </fieldset>
                          </ItemTemplate>
                        <EmptyDataTemplate>
                            <fieldset style="width: 800px">
                                <legend>Customers</legend>No records for customers available.
                            </fieldset>
                        </EmptyDataTemplate>
                     </telerik:RadListView>
                </asp:Panel>
            </td>
        </tr>


    </table>
   <br />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:dbPortalConnectionString %>" 
        SelectCommand="SELECT * FROM [Architect]" >
    </asp:SqlDataSource>

 /div>
</form>
</body>
 </html>
 </asp:Content>

可能是可能的,因为您没有提到哪个是您页面的代码隐藏。将此作为第一行添加到您的aspx页面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="yourfile.aspx.cs" Inherits="YourProjectName.YourASPXPageName" %>

您的内容占位符中有一些内容是不允许的,因为您使用的是主控。控件上没有intellisense的原因是页面无法编译

删除这些标记:

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<body> 
<form id="form1" runat="server"> 


然后尝试编译你的应用程序。修复编译器抛出的任何错误并重新编译。一旦应用程序可编译,您的intellisense应该重新开始工作。

是的,我在这里找到了解决方案。。。我必须通过右键单击ProjectFolder并单击“转换为Web应用程序”将其转换为Web应用程序。智能感知开始工作

听起来你的codebehind文件乱七八糟。把你的ASPX页面和你的代码隐藏文件一起发布。好的,我把我的代码放进去。请检查一下。我只是把我的代码和代码放在这里,]只是不要复制它,替换你的值。克里斯·盖斯勒,谢谢你的关心,现在我删除了这些标签,即使它不起作用。。它可以很好地编译,但是当我需要.cs文件中的SqlDataSource时,Intellience没有显示它。而您正在键入SqlDataSource2?是,当我键入sqlDataSource1或sqlDataSource2时,即使我使用标签并尝试访问label1,也不会显示任何内容。而且它也不起作用..c#是区分大小写的。sqlDataSource2应该是sqlDataSource2是的,我知道我正在使用SqlDataSource1或sqlDataSource2,但它没有显示其属性。通过键入sql,它必须显示SqlDataSource1,但它没有显示。。
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<body> 
<form id="form1" runat="server">