私は、GridView1
コードビハインドからバインドしているを持っています。の列の1つは、次のようにGridView
依存しLabel1.Text
ます。
SqlCommand comd = new SqlCommand("SELECT Location_Profile_Name, " + Label1.Text + " FROM Home_Profile_Master", con);
SqlDataAdapter da = new SqlDataAdapter(comd);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
同じのaspxコードは次のとおりです。
<asp:TemplateField HeaderText="Location_Profile_Name"
SortExpression="Location_Profile_Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server"
Text='<%# Bind("Location_Profile_Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Home_Profile" SortExpression="Label10">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Home_Profile") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Home_Profile") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
aspxページで次のようなエラーが発生します:DataBinding:'System.Data.DataRowView'に'Home_Profile'という名前のプロパティが含まれていません。
私は間違いが何であるかを理解することができません。親切に助けて...!ありがとうございました。