我正在尝试使用DOTNETNUKE模块中的SQL dataadapter填充gridview。我的问题是我得到了重复的#34;当我这样做时。对我来说有什么见解吗?
这是我背后的代码
SqlCommand command = new SqlCommand();
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet ds = new DataSet();
SqlConnection connection = new SqlConnection(connString);
connection.Open();
command.Connection = connection;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "PopulateGridView";
adapter = new SqlDataAdapter(command);
adapter.Fill(ds);
connection.Close();
gvStatusUpdate.DataSource = ds.Tables[0];
gvStatusUpdate.DataBind();
这是我对于gridview的结束代码。
<asp:GridView ID="gvStatusUpdate" runat="server">
<Columns>
<asp:BoundField ReadOnly="True" HeaderText="ID" DataField="ID"></asp:BoundField>
<asp:BoundField HeaderText="ReportedDate" DataField="ReportedDate"></asp:BoundField>
<asp:BoundField HeaderText="CurrentStatus" DataField="CurrentStatus"></asp:BoundField>
<asp:BoundField HeaderText="ResolvedDate" DataField="ResolvedDate"></asp:BoundField>
<asp:BoundField HeaderText="Issue" DataField="Issue"></asp:BoundField>
</Columns>
</asp:GridView>
答案 0 :(得分:1)
将AutoGenerateColumns="False"
添加到GridView。
<asp:GridView ID="gvStatusUpdate" AutoGenerateColumns="False" runat="server">