Saturday, February 2, 2008

String Result = "";
foreach(DataGridItem dataGridItem in MyDataGrid.Items)
{

//Get name from cell[0]
String Name = dataGridItem.Cells[0].Text;

//Get text from textbox in cell[1]
String Age = ((TextBox)
dataGridItem.FindControl("AgeField")).Text;

//Get Checked property of Checkbox control
bool IsGraduate = ((CheckBox)dataGridItem.FindControl("IsGraduateField")).Checked;

// get Values from Checkboxlist
String Skills = "";
foreach(ListItem item in ((CheckBoxList)dataGridItem.FindControl("CheckBoxList1")).Items){
if (item.Selected)
{
Skills += item.Value + ",";
}
}
Skills = Skills.TrimEnd(',');

//Get RadioButtonList Selected text
String Experience = ((RadioButtonList)dataGridItem.FindControl("RadioButtonList1")).SelectedItem.Text;

//Get DropDownList Selected text String Degree = ((DropDownList)dataGridItem.FindControl("DropDownList1")).SelectedItem.Text;

// Build String to show result.
Result += Name;
Result += " [Age -" + Age + "] ";
if (IsGraduate)
{ Result += "Is Graduate , "; }
else{ Result += "Is not Graduate , "; }
Result += "Has Skills[" + Skills + "] , ";
Result += "Has " + Experience + " Experience , And " ;
Result += "Has " + Degree + " Degree." ;
Result += "
"; }
ResultField.Text = Result; }

No comments: