F
Frawls
I have a datagrid which contains an ImageButton.
This datagrid is in a control which is in an aspx page. the aspx page
contains the form:<form id="frmItemDetail" runat="server">
On my local machine the ImageButton submits my page fine. Everything
works fine locally. But when i deploy my site to the live server this
ImageButton will not even submit the page. thats right it doesnt EVEN
SUBMIT the page let alone submit it and then do nothing.
1 I have my databinding put inside if(!Page.IsPostBack) so that my
itemcommand does not get eaten when i click the imagebutton.
2 I have put the necessary code within private void
InitializeComponent()
3 I have created the necessary code for the item command private void
dgItemDetail_ItemCommand(object source, DataGridCommandEventArgs e)
4 i have added the CommandName atttribte to my ImageButton
I am completely stumped as to why this works fine on my local copy but
not on the live server.
I am hosting my site with a commercial hoster so i can attach a
debugger to the live process.
Here are some relevant bits of my code which may help. Any help would
be appreciated?????
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
<aspataGrid ID="dgItemDetail"
Runat="server"
BorderWidth="0"
PagerStyle-CssClass="Paging"
AllowPaging="false"
AllowSorting="true"
AutoGenerateColumns="false"
PageSize="8">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Label ID="lblLongDescription" Text='<%#
Convert.ToString(DataBinder.Eval(Container.DataItem,"ItemDescription"))
%>' Runat=server >
<asp:ImageButton ID="bttnAddToCart" ImageUrl="../Images/
buttonAddLarge.gif" CommandName="cmdAddToCart" Visible="True"
Runat="server"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</aspataGrid>
------------------------------------------------------------------------------------------------------------------------------------------------------------------
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.dgItemDetail.ItemDataBound +=new
DataGridItemEventHandler(dgItemDetail_ItemDataBound);
this.dgItemDetail.ItemCommand +=new
DataGridCommandEventHandler(dgItemDetail_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------
private void dgItemDetail_ItemCommand(object source,
DataGridCommandEventArgs e)
{
if(e.CommandName.ToString() != "Page") // paging command
{
//buttons
bttnAddToCart =
(ImageButton)e.Item.FindControl("bttnAddToCart");
if (((ImageButton)e.CommandSource).CommandName ==
"cmdAddToCart")
{
//add the item to the cart and redirect to the cart page
oCart.AddItemToCart(ItemID, dblChargeForMiniBasket,"0");
Page.Response.Redirect("SiteCart.aspx");
}
}
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
This datagrid is in a control which is in an aspx page. the aspx page
contains the form:<form id="frmItemDetail" runat="server">
On my local machine the ImageButton submits my page fine. Everything
works fine locally. But when i deploy my site to the live server this
ImageButton will not even submit the page. thats right it doesnt EVEN
SUBMIT the page let alone submit it and then do nothing.
1 I have my databinding put inside if(!Page.IsPostBack) so that my
itemcommand does not get eaten when i click the imagebutton.
2 I have put the necessary code within private void
InitializeComponent()
3 I have created the necessary code for the item command private void
dgItemDetail_ItemCommand(object source, DataGridCommandEventArgs e)
4 i have added the CommandName atttribte to my ImageButton
I am completely stumped as to why this works fine on my local copy but
not on the live server.
I am hosting my site with a commercial hoster so i can attach a
debugger to the live process.
Here are some relevant bits of my code which may help. Any help would
be appreciated?????
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
<aspataGrid ID="dgItemDetail"
Runat="server"
BorderWidth="0"
PagerStyle-CssClass="Paging"
AllowPaging="false"
AllowSorting="true"
AutoGenerateColumns="false"
PageSize="8">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Label ID="lblLongDescription" Text='<%#
Convert.ToString(DataBinder.Eval(Container.DataItem,"ItemDescription"))
%>' Runat=server >
<asp:ImageButton ID="bttnAddToCart" ImageUrl="../Images/
buttonAddLarge.gif" CommandName="cmdAddToCart" Visible="True"
Runat="server"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</aspataGrid>
------------------------------------------------------------------------------------------------------------------------------------------------------------------
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.dgItemDetail.ItemDataBound +=new
DataGridItemEventHandler(dgItemDetail_ItemDataBound);
this.dgItemDetail.ItemCommand +=new
DataGridCommandEventHandler(dgItemDetail_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------
private void dgItemDetail_ItemCommand(object source,
DataGridCommandEventArgs e)
{
if(e.CommandName.ToString() != "Page") // paging command
{
//buttons
bttnAddToCart =
(ImageButton)e.Item.FindControl("bttnAddToCart");
if (((ImageButton)e.CommandSource).CommandName ==
"cmdAddToCart")
{
//add the item to the cart and redirect to the cart page
oCart.AddItemToCart(ItemID, dblChargeForMiniBasket,"0");
Page.Response.Redirect("SiteCart.aspx");
}
}
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------