通过查询资料,以下方法测试成功。
但是它会在GridView出现两个"时间"字段,我想只出现一个"时间"字段,应该如何编写。<Columns>
    <asp:TemplateField HeaderText="时间">
        <ItemTemplate>
<asp:Label ID="lbl" runat="server" Text='<%# Bind("时间", "{0:yyyy年M月d日}") %>'></asp:Label>
        </ItemTemplate>
    </asp:TemplateField>
</Columns>--------------------------------------------------------------------------------------------------
后台:
        string sqlStr = "SELECT 货币,时间 FROM 测试表";        DataSet ds = new DataSet();
        bool ok = false;        conn.DataSetFunction(sqlStr, "测试表", ref ds);        gv.DataSource = ds.Tables["测试表"].DefaultView;
        gv.DataBind();        ds.Dispose();--------------------------------------------------------------------------------------------------
conn 类:
    public static void DataSetFunction(string sqlStr, string tableName, ref DataSet ds)
    {
        SqlConnection conn = new SqlConnection();
        conn.ConnectionString = CONNSTR;        conn.Open();        SqlDataAdapter da = new SqlDataAdapter(sqlStr, conn);        da.Fill(ds, tableName);        conn.Close();
        conn.Dispose();
        da.Dispose();
    }