I have achieved by using the following script with OnDataBound event:
string IPaddress;
protected void FormView1_OnDataBound(object sender, System.EventArgs e)
{
if (FormView1.CurrentMode == FormViewMode.Insert)
{
TextBox IPAdd = (TextBox)FormView1.FindControl("IPaddress");
if (IPAdd != null)
{
IPAdd.Text = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(IPAdd.Text))
IPAdd.Text = Request.ServerVariables["REMOTE_ADDR"];
}
}
}