The example in this article tells you how to access all the control values in the DataGrid in ASP.net. Share to everyone for your reference, specific as follows:
<%@ Page language= "C #"%> <%@ import namespace= system.collections "%>" <script runat= "Server" > void Pag E_load (Object sender, EventArgs e) {if (! Page.IsPostBack) {ArrayList data = new ArrayList (), data.
ADD (New person ("Tom", 33,true)); Data.
ADD (New person ("Jhon", 39,false)); Data.
ADD (New person ("Mark", 20,false)); Data.
ADD (New person ("Linda", 27,true));
Mydatagrid.datasource = data;
Mydatagrid.databind ();
} void Getvalues_click (Object sender, EventArgs e) {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 the 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 = "<br>";
} Resultfield.text = result; Class person{String _name int _age; bool _isgraduate; public person (String name,int age, bool isgraduate) {_name = Nam
E
_age = age;
_isgraduate = isgraduate; Public String name{Get{return _name} is public int age{Get{return _age;} public bool isgraduate{Get{return _isgradu
ate;} }} </SCRipt>