i have a gridview in web page
<asp:GridView ID="grid_search" runat="server" >
and it contains Footer for total value of Columns
i have a Column name Production value in Gridview
prod_val nvarchar(50)
for data bind i use the code behind
protected void grid_search_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
`tot_prodVal = tot_prodVal + Convert.ToDecimal(e.Row.Cells[2].Text);`
} }
but it shows an error at debugging time that
System.FormatException: Input string was not in a correct format.
plz g开发者_JS百科ive me solution..
Since you have mentioned footer in your question, I am guessing you want to perform that operation in the footer. So your if condition should be
e.Row.RowType == DataControlRowType.Footer
I guess because you are using DataRow in your condition, e.Row.Cells[2].Text doesn't really point to the field you want it to.
精彩评论