protected void Button1_Click(object sender, EventArgs e)
{
DropDownList dd = (DropDownList)GridView1.FindControl("DropDownList2");
int c = dd.Items.Count;
for (int i=0; i < c; i++) {
DropDownList ddl = (DropDownList)GridView1.Rows[i].FindControl("DropDownList2");
string str = ddl.SelectedItem.Value;
Response.Write(str);
}
//String fen=dd.SelectedValue.ToString();
//Response.Write(fen);
Response.Write("<script>alert('提?交?成é功|!?')</script>");
}
DropDownList dd = (DropDownList)GridView1.FindControl("DropDownList2");
string s = dd.SelectedValue;
就可以了。
你有多个dropdown,你需要给它们不同的name和id
DropDownList ddl = (DropDownList)GridView1.Rows[i].FindControl("DropDownList2");
->
DropDownList ddl = (DropDownList)GridView1.Rows[i].FindControl("DropDownList" + i.ToString());