gridview和checkboxlist的嵌套相关应用

gridview和checkboxlist的嵌套相关应用_第1张图片gridview和checkboxlist的嵌套相关应用_第2张图片gridview和checkboxlist的嵌套相关应用_第3张图片

复制代码 代码如下:



Width="100%" AutoGenerateColumns="false">










ID="gvInnerItem" OnSelectedIndexChanged="gvInnerItem_SelectChange" AutoPostBack="false">






onclick="selectAll()" />

复制代码 代码如下:

protected void gvItem_RowCommand(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
CheckBoxList oGridView = (CheckBoxList)e.Row.FindControl("gvInnerItem");
if (oGridView != null)
{
string state = gvItem.DataKeys[e.Row.RowIndex].Value.ToString();
string sql = string.Format("select distinct(city) from CELLPHONESORT where state='{0}'", state);
DataSet ds = MyDB.GetDataSet(sql);

oGridView.DataSource = ds.Tables[0].DefaultView;
oGridView.DataValueField = "city";
oGridView.DataTextField = "city";
oGridView.DataBind();
}
}
}

你可能感兴趣的:(gridview和checkboxlist的嵌套相关应用)