i am using a gridview in my web page,i used to bind the database records to the gridview..
my columns are name,empid,company name,pl leave,sl leave,total leave taken
here total leave taken is not a database fields,in the page i want to fill the records once loaded pl leave and sl leave is added and display in the total leave taken column..it working properly when all pl ans sl columns fill with numbers,if some pl and sl leave having blank values.it showing an error like input sting was not in correct format..
this is my code
<Columns>
<asp:BoundField DataField="slno" HeaderText="SerialNo"
SortExpression="slno" />
<asp:BoundField DataField="ecode" HeaderText="Employee Code"
SortExpression="empcode" />
<asp:BoundField DataField="ename" HeaderText="Employee Name"
SortExpression="empname" />
<asp:BoundField DataField="Cname" HeaderText="Company Name"
SortExpression="Cname" />
<asp:BoundField DataField="tpl" HeaderText="PL"
SortExpression="Year" />
<asp:BoundField DataField="tsl" HeaderText="SL"
SortExpression="tsl" />
<asp:BoundField HeaderText="Balance Leave" />
</Columns>
form1.aspx.vb
If Not IsPostBack Then
connection.Open()
cmd = New SqlCommand("select slno,ecode,ename,cname,tpl,tsl from LeaveApplication", connection)
Dim adapter As New SqlDataAdapter(cmd)
Dim dt As New DataTable
adapter.Fill(dt)
If dt.Rows.Count > 0 Then
GridView1.DataSource = dt
GridView1.DataBind()
End If
End If
For Each gr As GridViewRow In GridView1.Rows
gr.Cells(6).Text = (Integer.Parse(gr.Cells(4).Text) + Integer.Parse(gr.Cells(5).Text)).ToString()
Next
End Sub