日期:2014-05-16 浏览次数:20527 次
int i = 0;
for (i = 0; i < DataList1.Items.Count; i++)
{
string strSql = "select TypeNumber from tableC where TypeName='" + DataList1.Items[i].DataItem.ToString()+ "' ";
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace IM
{
public partial class WebForm17 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<string> list = new List<string>();
list.Add("test");
list.Add("test1");
list.Add("test2");
list.Add("test3");
DataList1.DataSource = list.Select(x => new { 字段1 = x });
DataList1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < DataList1.Items.Count; i++)
{
Response.Write(DataList1.DataKeys[i].ToString());
}
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm17.aspx.cs" Inherits="IM.WebForm17" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3