易截截图软件、单文件、免安装、纯绿色、仅160KB

在ASP.NET中访问DataGrid中所有控件的值

<%@ Page Language="C#" %>
<%@ import Namespace="System.Collections" %>
<script runat="server">
void Page_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 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 += "<br>";
}
ResultField.Text = Result;
}
class Person{
String _Name;
int _Age;
bool _IsGraduate;
public Person(String name,int age, bool isGraduate){
_Name = name;
_Age = age;
_IsGraduate = isGraduate;
}
public String Name{
get{return _Name;}
}
public int Age{
get{return _Age;}


相关文档:

ASP.NET技术的学习顺序问题

前前后后收到过一些学生的来信,询问ASP.NET的学习顺序问题,在此就向打算系统学习ASP.NET技术的初学者谈谈我的建议。
 
如果你已经有较多的面向对象开发经验,跳过以下这两步:
第一步 掌握一门.NET面向对象语言,C#或VB.NET。
       我强烈反对在没系统学过一门面向对象(OO) ......

Javascript 在ASP.net 母板页下访问 控件ID:

Javascript 在ASP.net 母板页下访问 控件ID:
对于 html control : 直接访问ID
document.getElementById("hfRespondID");
对于 Web control :
document.getElementById("<%= this.hfRespondID.ClientID %>") [注意大小写
]     
     &nb ......

asp.net 导出Excel

public bool SaveExcel(GridView paramGridView)
{
if (paramGridView.Rows.Count == 0)
{
return false;
}
//创建Excel对象
Microsoft.Office.Interop.Excel.Application myExcel = new Microsoft.Office.Interop.Excel.Appl ......

asp.net 发送邮件

web.config
    <system.net>
        <mailSettings>
            <smtp deliveryMethod="Network" from="mymail&lt;you@163.com&gt;">
       ......

Asp.net 页面传值之 @ PreviousPageType 指令。

给出如下例子 我只知道这样做可以调用上一个页面 的值或者方法 但是我不知道原理和它的优略
请高手 加以指点 大家共同学习 谢谢!
1.Default.aspx 页面
protected void but1_Click(object sender, EventArgs e)
    {
        Server.Transfer("Default2.aspx"); ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号