I'm using NA 2010 Volume 3 SR 2134, VS2010 and .NET 4.0 and trying to get ItemCommand to fire without success, using the following code:
<ig:WebDataGrid ID="WebDataGrid1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource4" Width="958px" StyleSetName="Office2010Blue"
StyleSetPath="~/App_Themes" OnItemCommand="WebDataGrid1_ItemCommand"
oninitializerow="WebDataGrid1_InitializeRow">
<Columns>
<ig:BoundDataField DataFieldName="report_id" Hidden="True" Key="report_id"><Header Text="report_id" /></ig:BoundDataField>
<ig:BoundDataField DataFieldName="report_no" Key="report_no" Width="10%"><Header Text="Report No." /></ig:BoundDataField>
<ig:BoundDataField DataFieldName="report_title" Key="report_title" Width="40%"><Header Text="Title" /></ig:BoundDataField>
<ig:BoundDataField DataFieldName="report_date" Key="report_date" Width="10%"
DataFormatString="{0:yyyy'-'MM'-'dd}" DataType="System.DateTime"><Header Text="Date" />
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="type_name" Key="type_name" Width="10%"><Header Text="Type" /></ig:BoundDataField>
<ig:BoundDataField DataFieldName="location_name" Key="location_name" Width="20%"><Header Text="Location" /></ig:BoundDataField>
<ig:BoundDataField DataFieldName="report_online" Hidden="true" Key="report_online" Width="10%"><Header Text="Download" /></ig:BoundDataField>
<ig:TemplateDataField Key="report_online2" Width="10%" CssClass="gridImage">
<ItemTemplate>
<igtxt:WebImageButton ID="WebImageButtonX" runat="server" Height="20px"
Text="Text" UseBrowserDefaults="False" CommandName="Download"
CommandArgument='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "report_no") %>'>
<Alignments TextImage="TextRightImageLeft" VerticalImage="Middle"/>
<Appearance>
<ButtonStyle BackColor="#F0F0F0" BorderColor="#CBCBCB" BorderStyle="Solid"
BorderWidth="1px" Cursor="Hand" Font-Names="Arial" Font-Size="X-Small">
</ButtonStyle>
</Appearance>
<HoverAppearance>
<ButtonStyle BackColor="#CBCBCB" BorderColor="#A5A5A5" BorderStyle="Solid" BorderWidth="1px"></ButtonStyle>
</HoverAppearance>
</igtxt:WebImageButton>
</ItemTemplate>
<Header Text="Availability" />
</ig:TemplateDataField>
</Columns>
<AjaxIndicator ImageUrl="~/App_Themes/Office2010Blue/images/ig_ajaxIndicator.gif"
Location="MiddleCenter" RelativeToControl="True" />
<Behaviors>
<ig:ColumnResizing></ig:ColumnResizing>
<ig:Paging PageSize="10" QuickPages="4" FirstPageText="First"
LastPageText="Last" NextPageText="Next" PagerMode="NumericFirstLast"></ig:Paging>
<ig:RowSelectors RowNumbering="True"></ig:RowSelectors>
<ig:Selection CellClickAction="Row" EnableCrossPageSelection="True" RowSelectType="Multiple"></ig:Selection>
<ig:Sorting></ig:Sorting>
</Behaviors>
<EmptyRowsTemplate>
<asp:Label ID="Label1" runat="server" Text="No Result"></asp:Label>
</EmptyRowsTemplate>
</ig:WebDataGrid>
protected void WebDataGrid1_ItemCommand(object sender, Infragistics.Web.UI.GridControls.HandleCommandEventArgs e)
{
if (e.CommandName == "Download")
try
string mypath = Server.MapPath("./reports/") + "\\" + string.Format("{0}.pdf", e.CommandArgument.ToString());
System.IO.FileInfo file = new System.IO.FileInfo(mypath);
if (file.Exists)
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/pdf";
Response.WriteFile(file.FullName);
Response.End();
Response.Flush();
}
else
literalErrorMessage.Text = "The report is not available for download.";
catch (Exception exception)
literalErrorMessage.Text = exception.Message;
It seems that the ItemCommand never gets fired. Putting a breakpoint in the ItemCommand method does nothing.
I had same issue, even I have put EnableAjax="false" but this is fixed now by adding EnableDataViewState="true" in grid
here is sample code
<ig:WebDataGrid ID="gvEFHistoryList" AutoGenerateColumns="False" EnableAjax="false" DataKeyFields="EligibilityFacilityID" Width="100%" OnDataFiltering="gvEFHistoryList_DataFiltering" OnPageIndexChanged="gvEFHistoryList_PageIndexChanged" OnItemCommand="gvEFHistoryList_ItemCommand" runat="server" EnableDataViewState="true">
Disbaling Ajax has the desired effect. The ajax indicator doesn't show anymore when paging but I can live with that. Thank you Tsvetelina.
Disabling Ajax has the desired effect. The ajax indicator doesn't show anymore when paging but I can live with that.
Thank you Tsvetelina
Hello Casper,
Thank you for the update.
In this scenarios you should disable the Ajax of the WebDataGrid in order to get ItemCommand to fire
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" EnableAjax="false">
Let me know if you still expeirence the issue after that.
Hi Tsvetelina,
Finally some good news. I've re-traced, re-tested and found that the ItemCommand is firing correctly as it should. It seems the problem appears after a filter is applied, or a column is sorted or the grid has been paged.
When the page loads the first time, the first 10 records are displayed and the itemcommand is firing when clicking the button.
However, after a filter, sort or page event, when I click on the button, nothing happens, but also, the grid receives a focus and the whole row is selected.
To answer your previous question, I'm using Windows XP SP 3 + IE 8.