protected void CreateTable_Click(object sender, EventArgs e)
    {
        List<string> FieldNames = new List<string>();
        List<string> DataTypes = new List<string>();
        list = (List<ListOfItems>)GridView1.DataSource;
        //GridView1.DataSource = list;
        //GridView1.DataBind();

        foreach (TableRow item in GridView1.Rows)
        {

            TextBox txtName = (TextBox)item.Cells[0].FindControl("TextBox1");
            FieldNames.Add(txtName.Text);
            TextBox txtdata = (TextBox)item.Cells[1].FindControl("txtData");
            if (txtdata.Text == "int" || txtdata.Text == "nvarchar(MAX)" || txtdata.Text == "float")
                DataTypes.Add(txtdata.Text);
            else
            {
                Label2.Visible=true;
                return;
            }

        }
        localhost.Service serviceObj = new localhost.Service();
        int objid = -1;
        int counter = 0;
        bool flag = false;
        if( TextBox2.Text != "")
        {
        foreach (string item in FieldNames)
        {
            if(TextBox2.Text == item )
            {
                string[] arrayfields = FieldNames.ToArray();
                string[] arraydatatype = DataTypes.ToArray();
                objid = serviceObj.CreateObject((int)Session["orgID"], txt1.Text,arrayfields, arraydatatype,counter);
                flag = true;
                break;
            }
            counter++;

        }
        }
        if( flag == false && TextBox2.Text == "")
             objid = serviceObj.CreateObject((int)Session["orgID"], txt1.Text, FieldNames.ToArray(), DataTypes.ToArray(),-1);

        if (objid < 0)
            Label1.Visible = true;
        else
        {
            Session["objID"] = objid;
            Response.Redirect("AddRelationships.aspx");
        }
    }