scXB0XL3GEND
New Member
I have a \[code\]GridView1\[/code\], which I am binding from code behind. The one of the columns in the \[code\]GridView\[/code\] depends on \[code\]Label1.Text\[/code\] as follows:\[code\]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();\[/code\]The aspx code for the same is :\[code\]<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>\[/code\]I am getting an error in the aspx page as: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Home_Profile'.I am not able to figure out what the mistake is. Kindly Help...! thank you.