Gridview に重複した行が表示されています。私のデータベースには重複する行が含まれていません。私は AutoGenerateColumns="false" を試しました。これは重複を削除するだけでなく、Gridview からすべてのデータを削除します。つまり、行は表示されません。
以下は私のグリッドビューコードです
<asp:GridView ID="GridView1" runat="server"
style="margin-bottom: 10px; margin-top: 10px;" HorizontalAlign="Center" BackColor="White"
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3"
EnableModelValidation="True" GridLines="Horizontal">
<AlternatingRowStyle BackColor="#F7F7F7" />
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
</asp:GridView>
以下に示すのは、私の aspx.cs ファイルのコードです
SqlConnection connection;
SqlDataAdapter adapter;
DataSet ds = new DataSet();
DataTable dt = new DataTable();
connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Z\Documents\Visual Studio 2010\Projects\FF\FF\App_Data\Database1.mdf;Integrated Security = true; User Instance = true");
//*****Show Table Data****
string ss = @"
SELECT person.[account type],
person.email,
person.name,
person.gender,
person.dob,
person.country,
person.city,
person.nationality,
person.cnic,
person.person_id,
degree.degreelevel,
degree.degreetitle,
degree.majorsubject,
degree.country AS Expr1,
degree.institution,
degree.completionyear,
degree.degree_id,
degree.person_id AS Expr2,
professional.haveworkexperience,
professional.areaofinterest,
professional.functionalarea,
professional.careerlevel,
professional.firstjobstartdate,
professional.workexperience,
professional.professionalindutry,
professional.professional_id,
professional.person_id AS Expr3,
phone.phonenumber,
phone.phone_id,
phone.person_id AS Expr4,
recentjob.recentjobtitle,
recentjob.jobperiodfromdate,
recentjob.jobperiodtodate,
recentjob.country AS Expr5,
recentjob.companyname,
recentjob.city AS Expr6,
recentjob.job_id,
recentjob.person_id AS Expr7
FROM person
CROSS JOIN degree
CROSS JOIN professional
CROSS JOIN phone
CROSS JOIN recentjob";
connection.Open();
SqlCommand cmds = new SqlCommand(ss, connection);
adapter = new SqlDataAdapter(cmds);
adapter.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();