Hi,
this is shanker am doing one project .My requirement is hierarchy of radgrid and several table sat a level .I am doing multi hierarchy in single level hierarchy grid i have multiple detail tables in rad grid How to difference in item data bound event
hot difference detail stables in item databound event and insert and update and delete in manule code
this my code
example
GridTableView tableView = e.Item.OwnerTableView;
if (e.Item.OwnerTableView.Name == "student")
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
int? eventId = GetEventId(e.Item);
if (e.Item.OwnerTableView.IsItemInserted)
{
//item is about to be inserted
}
else
{
if (eventId.HasValue)
{
var det = studentinformation.sch_view_student_profile_detail(eventId.Value);
if (det != null)
{
TextBox txtFristname = e.Item.FindControl("txtFristname") as TextBox;
if (txtFristname != null)
{
txtFristname.Text = det.first_name;
}
TextBox txtLastName = e.Item.FindControl("txtLastName") as TextBox;
if (txtLastName != null)
{
txtLastName.Text = det.last_name;
}
TextBox txtMiddleName = e.Item.FindControl("txtMiddleName") as TextBox;
if (txtMiddleName != null)
{
txtMiddleName.Text = det.middle_name;
}
TextBox txtAdmission = e.Item.FindControl("txtAdmission") as TextBox;
if (txtAdmission != null)
{
txtAdmission.Text = det.admission_number;
}
RadioButtonList rdbgender = e.Item.FindControl("rdbgender") as RadioButtonList;
if (rdbgender != null)
{
rdbgender.SelectedValue = det.gender;
}
RadDatePicker rdp_start_date = e.Item.FindControl("rdp_start_date") as RadDatePicker;
if (rdp_start_date != null)
{
rdp_start_date.SelectedDate = det.date_of_birth;
}
RadDatePicker rdp_end_date = e.Item.FindControl("rdp_end_date") as RadDatePicker;
if (rdp_end_date != null)
{
rdp_end_date.SelectedDate = det.Admission_date;
}
CheckBox check = e.Item.FindControl("ficalyearcheck") as CheckBox;
{
if (check != null)
{
check.Checked = det.Active;
}
}
}
}
}
}
}
if (e.Item.OwnerTableView.Name == "parent")
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
int? eventId = GetEventId(e.Item);
RadComboBox Existingperson = e.Item.FindControl("Existingperson") as RadComboBox;
if (Existingperson != null)
{
Existingperson.DataSource = studentinformation.org_view_person_lookup();
Existingperson.DataBind();
}
RadComboBox Relationship = e.Item.FindControl("Relationship") as RadComboBox;
if (Relationship != null)
{
Relationship.DataSource = studentinformation.org_view_relationship_lookup();
Relationship.DataBind();
}
RadComboBox Designation = e.Item.FindControl("Designation") as RadComboBox;
if (Designation != null)
{
Designation.DataSource = studentinformation.org_view_designation_lookup();
Designation.DataBind();
}
if (e.Item.OwnerTableView.IsItemInserted)
{
//item is about to be inserted
}
else
{
if (eventId.HasValue)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
int? parent_person_id = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["parent_person_id"].ToString().GetInteger();
var det = studentinformation.sch_view_student_parent_relationship_detail(eventId.Value, parent_person_id);
if (det != null)
{
if (det.parent_person_id != null)
{
Existingperson.SelectedIndex = Existingperson.Items.IndexOf(Existingperson.Items.FindItemByValue(det.parent_person_id.ToString()));
}
if (det.relationship != null)
{
Relationship.SelectedIndex = Relationship.Items.IndexOf(Relationship.Items.FindItemByText(det.relationship.ToString()));
}
if (det.designation != null)
{
Designation.SelectedIndex = Designation.Items.IndexOf(Designation.Items.FindItemByText(det.designation.ToString()));
}
TextBox txtfristname = e.Item.FindControl("txtfristname") as TextBox;
if (txtfristname != null)
{
txtfristname.Text = det.parent_first_name;
}
TextBox txtMiddlename = e.Item.FindControl("txtMiddlename") as TextBox;
if (txtMiddlename != null)
{
txtMiddlename.Text = det.parent_middle_name;
}
TextBox txtLastname = e.Item.FindControl("txtLastname") as TextBox;
if (txtLastname != null)
{
txtLastname.Text = det.parent_last_name;
}
RadDatePicker rdp_end_date = e.Item.FindControl("rdp_end_date") as RadDatePicker;
if (rdp_end_date != null)
{
rdp_end_date.SelectedDate = det.parent_date_of_birth;
}
RadioButtonList parentrdgender = e.Item.FindControl("parentrdgender") as RadioButtonList;
if (parentrdgender != null)
{
parentrdgender.SelectedValue = det.parent_gender;
}
}
}
}
}
}
if (e.Item.OwnerTableView.Name == "misc")
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
int? eventId = GetEventId(e.Item);
RadComboBox Monther_tongue = e.Item.FindControl("Monther_tongue") as RadComboBox;
if (Monther_tongue != null)
{
Monther_tongue.DataSource = studentinformation.org_view_language_lookup();
Monther_tongue.DataBind();
}
RadComboBox primary_contact = e.Item.FindControl("primary_contact") as RadComboBox;
if (primary_contact != null)
{
primary_contact.DataSource = studentinformation.sch_view_student_parent_lookup(eventId);
primary_contact.DataBind();
}
if (e.Item.OwnerTableView.IsItemInserted)
{
//item is about to be inserted
}
else
{
if (eventId.HasValue)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
var det = studentinformation.sch_view_student_misc_info_detail(eventId.Value);
if (det != null)
{
if (det.mother_tongue != null)
{
Monther_tongue.SelectedIndex = Monther_tongue.Items.IndexOf(Monther_tongue.Items.FindItemByText(det.mother_tongue.ToString()));
}
if (det.parent_name != null)
{
primary_contact.SelectedIndex = primary_contact.Items.IndexOf(primary_contact.Items.FindItemByText(det.parent_name.ToString()));
}
TextBox txtMole1 = e.Item.FindControl("txtMole1") as TextBox;
if (txtMole1 != null)
{
txtMole1.Text = det.mole1;
}
TextBox txtMole2 = e.Item.FindControl("txtMole2") as TextBox;
if (txtMole2 != null)
{
txtMole2.Text = det.mole2;
}
TextBox txtMole3 = e.Item.FindControl("txtMole3") as TextBox;
if (txtMole3 != null)
{
txtMole3.Text = det.mole3;
}
}
}
}
}
}
if (e.Item.OwnerTableView.Name == "address")
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
int? eventId = GetEventId(e.Item);
RadComboBox person = e.Item.FindControl("person") as RadComboBox;
if (person != null)
{
person.DataSource = studentinformation.sch_view_student_parent_lookup(eventId);
person.DataBind();
}
RadComboBox Adresstype = e.Item.FindControl("Adresstype") as RadComboBox;
if (Adresstype != null)
{
Adresstype.DataSource = studentinformation.org_view_address_type_lookup();
Adresstype.DataBind();
}
RadComboBox city = e.Item.FindControl("city") as RadComboBox;
if (city != null)
{
city.DataSource = studentinformation.org_view_city_lookup();
city.DataBind();
}
RadComboBox Postal_code = e.Item.FindControl("Postal_code") as RadComboBox;
if (city != null)
{
Postal_code.DataSource = studentinformation.org_view_postal_code_city_lookup();
Postal_code.DataBind();
}
if (e.Item.OwnerTableView.IsItemInserted)
{
//item is about to be inserted
}
else
{
int? parent_person_id = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["parent_person_id"].ToString().GetInteger();
int? address_type_id = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["address_type_id"].ToString().GetInteger();
if (address_type_id.HasValue)
{
var det = studentinformation.sch_view_student_parent_address_detail(parent_person_id, address_type_id);
if (det != null)
{
TextBox txtAdress1 = e.Item.FindControl("txtAdress1") as TextBox;
if (txtAdress1 != null)
{
txtAdress1.Text = det.address1;
}
TextBox txtAdress2 = e.Item.FindControl("txtAdress2") as TextBox;
if (txtAdress2 != null)
{
txtAdress2.Text = det.address2;
}
TextBox txtAdress3 = e.Item.FindControl("txtAdress3") as TextBox;
if (txtAdress3 != null)
{
txtAdress3.Text = det.address3;
}
}
}
}
}
}
if (e.Item.OwnerTableView.Name == "phone")
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
int? eventId = GetEventId(e.Item);
RadComboBox person = e.Item.FindControl("person") as RadComboBox;
if (person != null)
{
person.DataSource = studentinformation.sch_view_student_parent_lookup(eventId);
person.DataBind();
}
RadComboBox Phonetype = e.Item.FindControl("Phonetype") as RadComboBox;
if (Phonetype != null)
{
Phonetype.DataSource = studentinformation.org_view_address_type_lookup();
Phonetype.DataBind();
}
RadComboBox STD = e.Item.FindControl("STD") as RadComboBox;
if (STD != null)
{
STD.DataSource = studentinformation.org_view_phone_std_lookup();
STD.DataBind();
}
if (e.Item.OwnerTableView.IsItemInserted)
{
//item is about to be inserted
}
else
{
int? parent_person_id = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["parent_person_id"].ToString().GetInteger();
int? address_type_id = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["address_type_id"].ToString().GetInteger();
if (address_type_id.HasValue)
{
var det = studentinformation.sch_view_student_parent_phone_detail(parent_person_id, address_type_id);
if (det != null)
{
TextBox txtPhone = e.Item.FindControl("txtPhone") as TextBox;
if (txtPhone != null)
{
txtPhone.Text = det.phone_number;
}
TextBox txtExtension = e.Item.FindControl("txtExtension") as TextBox;
if (txtExtension != null)
{
txtExtension.Text = det.std_number;
}
}
}
}
}
}
It's argent Am stopped my project this issue please hot to solve that please forward any example
thanks and regards
shanker.B