CS Code:
1
private void Page_Load(object sender, System.EventArgs e)
2
{
3
if(!Page.IsPostBack)
4
{
5
BindData();
6
}
7
}
8
private void BindData()
9
{
10
string XmlPath=Server.MapPath("Test.xml");
11
DataSet MyDs = new DataSet();
12
MyDs.ReadXml(XmlPath);
13
int RowsCount = MyDs.Tables[0].Rows.Count;//Get rows of DataSet's data;
14
for (int x = 0;x<RowsCount;x++)
15
{
16
MyDs.Tables[0].Rows[x]["src" ]=MyDs.Tables[0].Rows[x]["src"].ToString() + "This is added before Bind to controls";//Edit data ,you can do some other things here to edit data;
17
}
18
this.myDataList.DataSource=MyDs;
19
this.myDataList.DataBind();//Bind data ,now,the data has been changed ;
20
myCn.Close();
21
}
22
//Thats all;
private void Page_Load(object sender, System.EventArgs e) 2
{ 3
if(!Page.IsPostBack) 4
{ 5
BindData(); 6
} 7
} 8
private void BindData() 9
{ 10
string XmlPath=Server.MapPath("Test.xml"); 11
DataSet MyDs = new DataSet(); 12
MyDs.ReadXml(XmlPath); 13
int RowsCount = MyDs.Tables[0].Rows.Count;//Get rows of DataSet's data; 14
for (int x = 0;x<RowsCount;x++) 15
{ 16
MyDs.Tables[0].Rows[x]["src" ]=MyDs.Tables[0].Rows[x]["src"].ToString() + "This is added before Bind to controls";//Edit data ,you can do some other things here to edit data; 17
} 18
this.myDataList.DataSource=MyDs; 19
this.myDataList.DataBind();//Bind data ,now,the data has been changed ; 20
myCn.Close(); 21
} 22
//Thats all;



浙公网安备 33010602011771号