Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net web服务数据集,输出的自定义字段_Asp.net - Fatal编程技术网

Asp.net web服务数据集,输出的自定义字段

Asp.net web服务数据集,输出的自定义字段,asp.net,Asp.net,我有我的web服务来检索数据,我的问题是我使用gridview来输出数据,我从表中获取所有字段,我只需要选择几个字段,我如何才能做到这一点 这是我的密码: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; public partia

我有我的web服务来检索数据,我的问题是我使用gridview来输出数据,我从表中获取所有字段,我只需要选择几个字段,我如何才能做到这一点

这是我的密码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class _Default : System.Web.UI.Page
{

public static DataSet ds;

protected void Page_Load(object sender, EventArgs e)
{
    localhost.Service1 myws = new localhost.Service1();
    ds = myws.GetDataSet();
    GridView1.DataSource = ds;
    GridView1.DataBind();
}
}

感谢您使用每个结果行的Datagrid designer和dataitem属性,编辑Datagrid以仅显示您想要显示的列

单击箭头,然后选择编辑列为要显示的每列添加绑定列。列名必须与数据库中字段的名称相同

确保将datagrid设置为AutoGenerate columns=false

发出的html代码应如下所示:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
        <Columns>
            <asp:BoundField DataField="DatabaseColumn1" /> Where DatabaseColumn1 is the name of the field you wish to display.
            <asp:BoundField DataField="DatabaseColumn2" />
        </Columns>

    </asp:GridView>

\我已经试过了,如果我在“设计”视图中单击网格上的箭头,我应该单击“下一步”什么?我好像找不到它。