ASP.NET Print from grid view error
Server Error in '/' Application.
The format of the input string is incorrect.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: تنسيق سلسلة الإدخال غير صحيح.
Source Error:
Line 346: protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
Line 347: {
Line 348: int rowIndex = Convert.ToInt32(e.CommandArgument);
Line 349: GridViewRow row = gvFiles.Rows[rowIndex];
Line 350:
Source File: C:\project_new 2\gsc\Admin\Vacations.aspx.cs Line: 348
when i try print, i get this error
my code html:
<asp:GridView ID="gvFiles" runat="server" AutoGenerateColumns="False" DataKeyNames="Id"
OnRowDataBound="OnRowDataBound" OnRowEditing="OnRowEditing" OnRowCancelingEdit="OnRowCancelingEdit"
OnRowUpdating="OnRowUpdating" OnRowDeleting="OnRowDeleting" OnRowCommand="GridView1_RowCommand" EmptyDataText="لاتوجد مواعيد جديده" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" Width="100%" ForeColor="Black" GridLines="Vertical" ShowFooter="True">
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:TemplateField HeaderText="Print">
<ItemTemplate>
<asp:Button ID="btnNewWindow" runat="server" Text="Print" OnClick="OpenWindow"></asp:Button>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="50px" />
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#FFFFCC" />
<FooterStyle BackColor="#FFFFCC" ForeColor="Red" HorizontalAlign="Center" BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" Height="30px" />
<HeaderStyle BackColor="#0A6EB2" Font-Bold="True" ForeColor="White" Font-Size="Large" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
code behind C#:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int rowIndex = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gvFiles.Rows[rowIndex];
txtSearch.Text = (row.FindControl("lblidcivilv") as Label).Text;
}