我在做這從表中的SQL獲取數據的動態頁面,並顯示記錄的使用文字HTML複選框。訪問HTML複選框值在asp.net
如何通過提交按鈕訪問它們?
相關代碼:
protected void Page_Load(object sender, EventArgs e)
{
Literal1.Text = DisplayAll();
}
protected string DisplayAll()
{
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
string queryString = "SELECT distinct Country FROM Customers";
SqlDataAdapter adapter = new SqlDataAdapter(queryString, connectionString);
string countrylist = "";
DataSet dscustomers = new DataSet();
DataTable dtCustomer=new DataTable();
adapter.Fill(dscustomers, "Customers");
dtCustomer = dscustomers.Tables[0];
for (int i = 1; i < dtCustomer.Rows.Count; i++)
{
countrylist = countrylist + "<input type='checkbox' ID='chk"+i.ToString()+"' value='"
+ dtCustomer.Rows[i]["Country"] + "' runat='server'>" + dtCustomer.Rows[i]["Country"] + "<br>";
}
return countrylist;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
?????????
}
你有沒有嘗試設置 「名稱」 爲複選框_屬性「 _在_DisplayAll()_和_Request.Form [「chkX」],其中X = 1,2,3 ..._在_btnSubmit_Click()_? – Coder