62,268
社区成员
发帖
与我相关
我的任务
分享
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowupdating="GridView1_RowUpdating">
<Columns>
<asp:BoundField />
<asp:BoundField DataField="EmployeeID" HeaderText="编号" />
<asp:BoundField DataField="LastName" HeaderText="LastName" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" />
<asp:BoundField DataField="Title" HeaderText="Title" />
<asp:BoundField DataField="BirthDate" DataFormatString="{0:yyyy年M月dd日}" HeaderText="BirthDate" HtmlEncode="False" />
<asp:BoundField DataField="Address" HeaderText="Address" />
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="0" Selected="True">第一项</asp:ListItem>
<asp:ListItem Value="1">第二项</asp:ListItem>
<asp:ListItem Value="2">第三项</asp:ListItem>
<asp:ListItem Value="3">第四项</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
protected void Button1_Click(object sender, EventArgs e)
{
string strTest = "";
for(int i=0; i<GridView1.Rows.Count; i++)
{
DropDownList ddlst = (DropDownList)GridView1.Rows[i].FindControl("DropDownList1");
strTest += i.ToString() + ddlst.SelectedIndex.ToString() + "<br>";
}
Response.Write(strTest);
}