我在显示数据时遇到问题。并非所有数据都在显示。单击名称后,将显示此人的数据。但是这里的问题是数据仅显示一个,但实际上在数据库中该人的数据有多个。谁能帮我如何显示所有数据?
我的数据库表
LanguageID TechnicalProfile_ID LanguageName SpokenLevel WrittenLevel
1 15 English 10 10
2 15 Mandarin 5 5
3 15 Spanish 3 2
4 16 English 10 9
5 17 Tamil 10 10
6 17 Tagalog 10 10
单击“技术档案ID” 15时我系统的输出,它仅显示“技术档案ID”的一个数据,而不显示3个数据。我该如何解决?
输出
Language SpokenLevel WrittenLevel
Spanish 3 2
我想要的输出如下:
Language SpokenLevel WrittenLevel
English 10 10
Mandarin 5 5
Spanish 3 2
我的代码如下:
ASPX
<div class="card-body">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:CheckBoxList class="list-group-item" ID="chkResourceName1" runat="server" AutoPostBack ="true" OnSelectedIndexChanged ="ResourceName_Click"></asp:CheckBoxList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="chkResourceName1"/>
</Triggers>
</asp:UpdatePanel>
</div>
<div role="tabpanel" class="tab-pane" id="language">
<asp:UpdatePanel ID="UpdatePanel15" runat="server">
<ContentTemplate>
<div class="form-horizontal" role="form">
<div class="form-group">
<div class="col-sm-4">
<b>Language</b>
</div>
<div class="col-sm-2">
<b>Written</b>
</div>
<div class="col-sm-2">
<b>Spoken</b>
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<asp:Label ID="lblLanguageName" runat="server"></asp:Label>
</div>
<div class="col-sm-2">
<asp:Label ID="lblLanguageWritten" runat="server"></asp:Label>
</div>
<div class="col-sm-2">
<asp:Label ID="lblLanguageSpoken" runat="server"></asp:Label>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
ASPX代码
Sub ResourceName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
Dim LanguageName As String = vbNullString
Dim WrittenRate As String = vbNullString
Dim SpokenRate As String = vbNullString
'To clear result
lblLanguageName.Text = ""
lblLanguageWritten.Text = ""
lblLanguageSpoken.Text = ""
attPage.SQLQuery = DC.Data_TechnicalResource("12", chkResourceName1.SelectedValue)
DS = DA.GetSQLDataset(attPage.SQLQuery)
If DS IsNot Nothing AndAlso DS.Tables(0).Rows.Count > 0 Then
lblLanguageName.Text = DS.Tables(0).Rows(0)("LanguageName").ToString
lblLanguageWritten.Text = DS.Tables(0).Rows(0)("WrittenLevel").ToString
lblLanguageSpoken.Text = DS.Tables(0).Rows(0)("SpokenLevel").ToString
End If
End Try
End Sub
SQL查询
BEGIN
SELECT *
From tblLanguage
where TechnicalProfile_ID = @Parameter1
END
答案 0 :(得分:0)
If DS IsNot Nothing AndAlso DS.Tables(0).Rows.Count > 0 Then
dim dr as datarow
for each dr in DS.tables(0).rows
lblLanguageName.Text = dr("LanguageName").ToString
lblLanguageWritten.Text = dr("WrittenLevel").ToString
lblLanguageSpoken.Text = dr("SpokenLevel").ToString
Next
这是for循环的工作方式,但是 lbLanguageName 不在表中,我认为最后一个值只会被打印出来。使用适当的表以加载所有值。