如何将 Devexpress Gridview 与从 API 检索到的 XML 数据绑定?
这是用于检索 XML 数据的 Sub(),现在我想使用相同的方法绑定 Devexpress GridView。我已经给出了下面的锥体片段:
Private Sub BindGridView()
Dim client As New RestClient("http://129.1.1.12:1111/")
client.Authenticator = New HttpBasicAuthenticator("username", "password")
Dim request As New RestRequest("user", Method.GET)
request.Resource = "user?action=get;id=19020020;format=xml"
request.Timeout = 10000
Dim authBytes As Byte() = Encoding.UTF8.GetBytes("username:password")
Dim authBase64 As String = Convert.ToBase64String(authBytes)
request.AddHeader("Authorization", "Basic " & authBase64)
Dim response As IRestResponse = client.Execute(request)
Console.WriteLine(response.Content)
ViewState("assigndevice") = response.Content
If response.StatusCode = HttpStatusCode.OK Then
Dim res = response.Content
Dim objDataObj As New SendDocResponse()
Dim objdata As String = res
If objdata IsNot Nothing Then
perform some action with strInfo variable
Dim strInfo As String = "some value"
End If
End If
End Sub
网格视图是:
<dx:ASPxGridView ID="gvDevice" runat="server" Width="50%" Theme="SoftOrange" AutoGenerateColumns="false" KeyFieldName="ID" ClientInstanceName="gvDevice"> <Columns>
<dx:GridViewDataTextColumn VisibleIndex="1" FieldName="ID" HeaderStyle-
HorizontalAlign="Center" Caption="Device ID" Width="15%" />
<dx:GridViewDataTextColumn VisibleIndex="2" FieldName="Name" HeaderStyle-
HorizontalAlign="Center" Caption="Device Name" Width="55%" />
<dx:GridViewDataHyperLinkColumn VisibleIndex="3" Caption="Edit" HeaderStyle-
HorizontalAlign="Center" CellStyle-HorizontalAlign="Center" Width="10%">
<DataItemTemplate>
<asp:LinkButton ID="lnkEdit" runat="server" CommandName="lnkEdit" OnClientClick="return ConfirmRemove();">Remove</asp:LinkButton>
</DataItemTemplate>
<CellStyle Cursor="pointer" Wrap="False"></CellStyle>
</dx:GridViewDataHyperLinkColumn>
</Columns>
<Styles>
<AlternatingRow Enabled="true" />
</Styles>
<Settings ShowGroupPanel="False" ShowFooter="True" ShowFilterRow="True" GridLines="Vertical" />
<SettingsBehavior AllowFocusedRow="True" AllowSelectSingleRowOnly="true" />
<SettingsPager Visible="true" PageSize="20" Mode="ShowPager" />
</dx:ASPxGridView>
检索到的 XML 数据:
<DocumentElement>
<user>
<id>19020020</id>
<reference-code>19020020</reference-code>
<name>ADMIN LOGIN</name>
<short-name>ADMIN LOGIN</short-name>
<active>1</active>
<module>U</module>
<date-of-birth/>
<joining-date/>
<confirmation-date/>
<leaving-date/>
<reason-for-leaving/>
<pf-no/>
<vehicle-reg-no/>
<visa-no/>
<visa-expiry/>
<driving-license/>
<pan/>
<esi-no/>
<passport-no/>
<aadhar-no/>
<uan/>
<voter-id/>
<height/>
<weight/>
<gender>NA</gender>
<blood-group>NA</blood-group>
<marital-status>NA</marital-status>
<nationality/>
<father-spouse-name/>
<qualification/>
<experience/>
<medical-history/>
<local-address1/>
<local-address2/>
<local-street/>
<local-city/>
<local-pincode/>
<local-state/>
<local-country/>
<permanent-address1/>
<permanent-address2/>
<permanent-street/>
<permanent-city/>
<permanent-pincode/>
<permanent-state/>
<permanent-country/>
<personal-phone/>
<personal-cell/>
<personal-email/>
<official-phone/>
<official-extension/>
<official-cell/>
<official-email/>
<pin/>
<card-1/>
<card-2/>
<access-validity-date/>
<active-directory-login>0</active-directory-login>
<active-directory-username/>
<active-directory-domain/>
<integration-reference/>
<organization>1</organization>
<branch>1</branch>
<department>2</department>
<designation>1</designation>
<section>1</section>
<category>1</category>
<grade>1</grade>
<leave_group>1</leave_group>
<reporting-incharge/>
<attendance-policy>1</attendance-policy>
<latein-policy>1</latein-policy>
<earlyout-policy>1</earlyout-policy>
<overtime-policy>1</overtime-policy>
<absentee-policy>1</absentee-policy>
<coff-policy>1</coff-policy>
<device-group/>
<device-group-id/>
<smart-access-route/>
<max-route-level>75</max-route-level>
<employment-profile/>
<employment-type/>
<award-penalty/>
<work-profile/>
<roster-policy/>
<roster-attendance-policy/>
<hour-exception/>
<access-level>8</access-level>
<bypass-finger>0</bypass-finger>
<bypass-palm>0</bypass-palm>
<shiftbased-access>0</shiftbased-access>
<shift-schedule>1</shift-schedule>
<start-shift>1</start-shift>
<holiday-schedule>1</holiday-schedule>
<attendance-calc>0</attendance-calc>
<max-personal-hrs>0</max-personal-hrs>
<bus-route/>
<bypass-finpalm>0</bypass-finpalm>
<ess-login/>
<ess-detail-edit/>
<attendance-via-ess/>
<allow-ecanteen/>
<discount-level/>
<account-type/>
<max-allowed-limit/>
<max-usage-limit/>
<organization_code>HO1</organization_code>
<branch_code>DXB</branch_code>
<department_code>RHSIT</department_code>
<designation_code>DSG1</designation_code>
<section_code>SEC1</section_code>
<category_code>CTG1</category_code>
<grade_code>GRD1</grade_code>
<field1/>
<field2/>
<field3/>
<field4/>
<week-off-group/>
<location-mandatory/>
<punch-api/>
<auto-attendance/>
<manual-punch/>
<allow-offline-punch/>
<capture-photo/>
<door-access-api/>
<fvm-enable>0</fvm-enable>
<blacklisted/>
<job-assignment-type>0</job-assignment-type>
<device>d_1,d_2</device>
<pvr_group>6</pvr_group>
<enrolled_fingers>0</enrolled_fingers>
<enrolled_palms>0</enrolled_palms>
<rg_id/>
<rg_name/>
<rg_incharge_1/>
<rg_incharge_2/>
<rg_incharge_3/>
<rg_incharge_4/>
<rg_incharge_5/>
<imei/>
<imei-authorized/>
<suprema-proprietary-count>0</suprema-proprietary-count>
<suprema-iso-count>0</suprema-iso-count>
<lumidigm-iso-count>0</lumidigm-iso-count>
<organization-name>RHS Group</organization-name>
<branch-name>Dubai</branch-name>
<department-name>IT Department</department-name>
<category-name>Category-1</category-name>
<grade-name>Grade-1</grade-name>
<designation-name>Designation-1</designation-name>
<section-name>Section-1</section-name>
<restrict-half-day>0</restrict-half-day>
<customgroup1ID>1</customgroup1ID>
<customgroup2ID>1</customgroup2ID>
<customgroup3ID>1</customgroup3ID>
<customgroup1_code>CG1</customgroup1_code>
<customgroup2_code>CG2</customgroup2_code>
<customgroup3_code>CG3</customgroup3_code>
<customgroup1_name>Custom Group 1</customgroup1_name>
<customgroup2_name>Custom Group 2</customgroup2_name>
<customgroup3_name>Custom Group 3</customgroup3_name>
<cafeteria-usage-policy/>
<show-atd-details>1</show-atd-details>
<full-name>MANAV SRIVASTAV</full-name>
<approval-policy/>
<approval-policy-name/>
<punch-marking-timezone/>
<enable-elevator-access-control>0</enable-elevator-access-control>
<elevator-floor-group/>
<enable-fr>1</enable-fr>
<enrolled_faces>10</enrolled_faces>
<auth-host-user>0</auth-host-user>
<face-mandatory/>
<blacklisted-reason/>
<pin-authentication/>
<driving-license-expiry/>
<passport-expiry/>
<punch-reason-flg/>
<field5/>
<field6/>
<field7/>
<field8/>
<field9/>
<field10/>
<lumidigm-proprietary-count>0</lumidigm-proprietary-count>
<uploaded-doc/>
<authorized-host-user>0</authorized-host-user>
<visitor-device-group-id/>
<visitor-device-group/>
<apta-face-anti-spoofing/>
<assigned_job>4294967293,4294967294,4294967295</assigned_job>
<enable-offline-transaction/>
<max-usage-limit-day/>
</user>
</DocumentElement>
在 Gridview 中我只想显示 d_1,d_2 值,即 第 1 行:d_1 第 2 行:d_2 列:设备 ID