J
Juba
Hello,
I have the following code placed at my Page_Load event and after the
Datagrid is binded, so it is not empty. The problem is that the variable
isclass is always returning null and I am sure that the Category
ItemTemplate is there and that it is previouly populated. Am I missing
something? Here's the code:
private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack == false)
{
// Calculate end-user's shopping cart ID
ShoppingCartDB cart = new ShoppingCartDB();
String cartId = cart.GetShoppingCartId();
// Populate datagrid with shopping cart data
MyDataGrid.DataSource = cart.GetItems(cartId);
MyDataGrid.DataBind();
// I am trying to get the value from my ItemTemplate TextBox here:
TextBox isclass = (TextBox)MyDataGrid.FindControl("Category");
if (isclass.Text == "Classes" ) // I am sure this value is there - it is
not finding the control
{
cart.AddItem(cartId, 2, 1);
}
}
}
.....
Thanks in advance!
I have the following code placed at my Page_Load event and after the
Datagrid is binded, so it is not empty. The problem is that the variable
isclass is always returning null and I am sure that the Category
ItemTemplate is there and that it is previouly populated. Am I missing
something? Here's the code:
private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack == false)
{
// Calculate end-user's shopping cart ID
ShoppingCartDB cart = new ShoppingCartDB();
String cartId = cart.GetShoppingCartId();
// Populate datagrid with shopping cart data
MyDataGrid.DataSource = cart.GetItems(cartId);
MyDataGrid.DataBind();
// I am trying to get the value from my ItemTemplate TextBox here:
TextBox isclass = (TextBox)MyDataGrid.FindControl("Category");
if (isclass.Text == "Classes" ) // I am sure this value is there - it is
not finding the control
{
cart.AddItem(cartId, 2, 1);
}
}
}
.....
Thanks in advance!