我有以下内容SqlDataSource,我想将其转换为DataView并从中读取一列:
SELECT
dbo.Divisions.DivisionShortcut,
COUNT(DISTINCT dbo.UserQuiz.Username) AS [Number of Participants]
FROM
dbo.Divisions
INNER JOIN
dbo.employee ON dbo.Divisions.SapCode = dbo.employee.DivisionCode
INNER JOIN
dbo.UserQuiz ON dbo.employee.Username = dbo.UserQuiz.Username
INNER JOIN
dbo.Quiz ON dbo.UserQuiz.QuizID = dbo.Quiz.QuizID
WHERE
(dbo.Quiz.QuizID = @QuizID)
GROUP BY
dbo.Divisions.DivisionShortcut
Run Code Online (Sandbox Code Playgroud)
这SqlDataSource允许用户输入测验的编号,它将检索该测验中的参与者总数.我想将其转换SqlDataSource为a DataTable并从中读取一列.
那怎么办呢?
我正在开发一个Intranet Web应用程序.我现在正在使用用户档案,其中显示了关于员工个人信息,培训课程,公司简短测验以及他提交的想法和建议的四个表格.
我现在想要的是,如果员工没有任何建议,表格内的信息(例如您没有任何建议),而不是显示带有标题的表而不告诉用户他没有建议.那怎么办呢?
我的ASP.NET代码:
<asp:Repeater ID="Repeater4" runat="server" DataSourceID="SqlDataSource4">
<HeaderTemplate>
<div>
<table border="1">
<thead>
<tr>
<td colspan="3">
<center> <strong>Safety Suggestions</strong> </center>
</td>
</tr>
<tr>
<td>
<center> <strong>Suggestion Title</strong> </center>
</td>
<td>
<center> <strong>Description</strong> </center>
</td>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<p>
<%# Eval("Title") %>
</p>
</td>
<td>
<p>
<%# Eval("Description") %>
</p>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</div>
</FooterTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource4" runat="server"
ConnectionString="<%$ ConnectionStrings:testConnectionString %>" SelectCommand="SELECT dbo.SafetySuggestionsLog.Title, dbo.SafetySuggestionsLog.Description, dbo.SafetySuggestionsLog.Username
FROM dbo.SafetySuggestionsLog INNER JOIN
dbo.employee ON dbo.SafetySuggestionsLog.Username = dbo.employee.Username …Run Code Online (Sandbox Code Playgroud)