简体   繁体   English

如何从Web服务向GridControl填充数据?

[英]How to populate data to GridControl from Web Service?

I have a problem with adding rows/cells values to GridControl. 我在向GridControl添加行/单元格值时遇到问题。 I am using Web Service as data source. 我正在使用Web服务作为数据源。 My web service function runs perfectly and returns an xml type of value eg 我的Web服务功能可以完美运行,并返回xml类型的值,例如

<User>
<UserID>000015</UserID>
<UserGroup>MR</UserGroup>
<UserName>ARIF SETYOWARDOYO</UserName>
<IsActive>1</IsActive>
</User>

I added my web service to my project as 'Add Services'. 我将Web服务作为“添加服务”添加到了项目中。 And, my BindingSource code: 而且,我的BindingSource代码:

userBindingSource.DataSource = typeof(DXWindowsApplication1.WebService.User);

I have attached my BindingSource to the GridControl, and it automatically creates 4 columns, which are UserID, UserGroup, UserName, and IsActive. 我已经将BindingSource附加到GridControl,它会自动创建4列,分别是UserID,UserGroup,UserName和IsActive。
but there's no data in their rows. 但他们的行中没有数据。 If I run this script below, it'd run and return the values.. 如果我在下面运行此脚本,它将运行并返回值。

WebService.MyWebServiceWs = new WebService.MyWebServiceWs ();
WebService.User[] user = Ws.GetUserDetails();
string userId = user[0].UserID.ToString();
string userGroup = user[0].UserGroup.ToString();
string userName = user[0].UserName.ToString();
string isActive = user[0].IsActive.ToString();//int isActive = user[0].IsActive.Value;



so my question is, what am I to do next to get retrieve this WebService data into GridControl? 所以我的问题是,接下来要怎么做才能将该WebService数据检索到GridControl中?
any reference would be really appreciated... 任何参考将不胜感激...
Thank You :) 谢谢 :)
Cheers.. 干杯..

i read xml from web without webservice,and poupolate my table with this code: 我从网络读取XML Web服务没有和poupolate我桌子下面的代码:

// needed variable
private DataSet ds;
//read xml and poupolate table
 System.Xml.XmlDataDocument xmlDatadoc = new System.Xml.XmlDataDocument();

                xmlDatadoc.DataSet.ReadXml("http://your link to xml");
                ds = xmlDatadoc.DataSet;



                datagridviwe1.DataSource = ds.DefaultViewManager;
                datagridviwe1.DataMember = "User";

but you need some change in our xml file,this is an example: 但是您需要在我们的xml文件中进行一些更改,这是一个示例:

<User UserID="000015" UserGroup="MR" UserName="ARIF SETYOWARDOYO" IsActive="1" />
<User UserID="000016" UserGroup="MRS" UserName="LADY LAYON" IsActive="0" />

This poupolate table with all value,for personalize showed content you need to bindingsource with your xsd schema and edit table generate. 这个具有全部价值的表,为了个性化显示的内容,您需要将源与xsd架构绑定并编辑表生成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM