我正在使用gridview并在gridview中使用下拉列表。
<div class="container" style="padding-right: 15px; padding-left: 15px; margin-top:auto">
<br /><br /><br />
<asp:GridView ID="grdUser" runat="server" AllowPaging="True" AllowSorting="True" CaptionAlign="Left" OnPageIndexChanging="grdUser_PageIndexChanging" OnSorting="grdUser_Sorting" PageSize="5" CssClass="table table-hover table-striped table-responsive">
<AlternatingRowStyle BackColor="#9999FF" />
<HeaderStyle BackColor="#009933" Font-Bold="True" Font-Size="Medium" HorizontalAlign="Center" VerticalAlign="Middle" />
<PagerSettings FirstPageText="First" Mode="NumericFirstLast" LastPageText="Last" PageButtonCount="4" NextPageText="" />
<PagerStyle BackColor="#FFFF66" HorizontalAlign="Right" VerticalAlign="Middle" ForeColor="Black" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="ddlAct" runat="server" OnSelectedIndexChanged="ddlAct_SelectedIndexChanged">
<asp:ListItem Value="Action">Action</asp:ListItem>
<asp:ListItem Value="Activate">Activate</asp:ListItem>
<asp:ListItem Value="Block">Block</asp:ListItem>
<asp:ListItem Value="Delete">Delete</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
好的,所以现在我想在特定行上隐藏网格中选定的行。
代码是:
public void GetDataTable()
{
string CS = ConfigurationManager.ConnectionStrings["FacebookConnectionString1"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = con;
cmd.CommandText = "select F_Name AS [First Name], S_Name AS [Surname], E_Mail AS [Email], Day+'-'+Month+'-'+Year AS [Birthday], Gender AS [Gender] from Users Order By F_Name";
cmd.CommandType = CommandType.Text;
if (con.State == ConnectionState.Closed)
con.Open();
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
dt.Clear();
dt.Load(dr);
grdUser.DataSource = dt;
grdUser.DataBind();
cmd.Dispose();
con.Close();
}
}
}
用于下拉选择索引更改我必须做什么?请帮帮我。
protected void ddlAct_SelectedIndexChanged(object sender, EventArgs e)
{
// what i'll be doing here ?
}