hello every body ... and thanx for yor time...
i have a gridview that it takes its List<> Collection datasource at runtime but does not view the collection content if the property:
AutoGenerateColumns
assigned to "False"
the code is:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating" Width="210px">
<Columns>
<asp:BoundField HeaderText="product id" />
<asp:BoundField HeaderText="name" />
<asp:CommandField ButtonType="Button" EditText="Change" InsertVisible="False"
ShowDeleteButton="True" ShowEditButton="True" />
</Columns>
<EmptyDataTemplate>
Your Cart Is Empty.
</EmptyDataTemplate>
<HeaderStyle BackColor="#8AB82E" ForeColor="White" />
</asp:GridView>
and
public partial class Default2 : System.Web.UI.Page
{
ShoppingCart cart;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["cart"] == null)
{
cart = new ShoppingCart();
Session["cart"] = cart;
}
else
{
cart = (ShoppingCart)Session["cart"];
}
GridView1.DataSource = cart.CartItems;//here CartItems is a List<CartItem>
//GridView1.AutoGenerateColumns = true; //if i uncomment this line that solve the problem partialy ... cuz all collumns of that collection will appear
//if (!Page.IsPostBack)
GridView1.DataBind();
any help is approciated ...