-1
这是我迄今(代码段)动态创建和使用LINQ查询在VB
ASP.NET标记做了结合ASP-的DataGrid:
<div class="Grid-style">
<asp:GridView ID="dgRequiredAttachment" runat="server" AutoGenerateColumns="false" DataKeyNames="Key">
<Columns>
<asp:BoundField HeaderText="Key" datafield="Key" SortExpression="Key" Visible="false"/>
<asp:BoundField HeaderText="Value" datafield="Value" SortExpression="Value"/>
</Columns>
</asp:GridView>
</div>
VB。 .NET代码:
Protected Sub ddlCitizenStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlCitizenStatus.SelectedIndexChanged
Dim context As New EGrantsModel.Entities
Dim attachmentType As New EGrantsModel.ATTACHMNTTYPE
Dim DC As Hashtable = New Hashtable
Dim orderCopyDesc As String = (From orderCopy In context.ATTACHMNTTYPEs Where orderCopy.ATTACHTYPEID = "1" Select orderCopy.DESCRIPTION).First
Dim notificationLtrDesc As String = (From notificationLetter In context.ATTACHMNTTYPEs Where notificationLetter.ATTACHTYPEID = "2" Select notificationLetter.DESCRIPTION).First
Dim citizenListDesc As String = (From citizenList In context.ATTACHMNTTYPEs Where citizenList.ATTACHTYPEID = "3" Select citizenList.DESCRIPTION).First
DC.Add("1", orderCopyDesc)
DC.Add("2", notificationLtrDesc)
DC.Add("3", citizenListDesc)
dgRequiredAttachment.DataSource = DC
dgRequiredAttachment.DataBind()
dgRequiredAttachment.Visible = True
End Sub
现在在该行
Dim DC As New Hashtable = New Hashtable
我想:您可以看到我使用LINQ查询动态创建HashTable。但是,如果我在Attachment
类型表中有超过3个条目,那么它将根据AttachmenttypeID
检查ATTACHMENTType
表中的所有值,并使用循环将项目填充/添加到散列表。
有人可以帮助我吗?
谢谢