protected void Button1_Click(object sender, EventArgs e) { if (DropDownList2.SelectedIndex >= 0 && DropDownList1.SelectedIndex >= 0) { lstOfTables = (List<localhost.Table>)ViewState["foreignkey"]; localhost.Table tableObj = lstOfTables[DropDownList2.SelectedIndex]; int index = DropDownList1.SelectedIndex; localhost.Field selectedField = FieldList[index]; localhost.Service serviceObj = new localhost.Service(); int orgID = (int)Session["orgID"]; int ObjID = (int)Session["objID"]; bool success = serviceObj.InsertRelationship(orgID, ObjID, tableObj.ObjIDProperty, selectedField.FieldIDProperty); if (success) Label3.Visible = true; else Label4.Visible = true; } }