//*****你在前在模版列定义一个CheckBoxList控件//****在RowDataBoud事件进行处理哈CheckBoxList ckbList=(CheckBoxList)e.RowItem.FindControl("ckbList");//****定一个函数邦寂静数据处理
CheckBoxListBind(ref ckBList,false);//****默认选择你需的项哈
for(int i=9;i<ckbList.Items.Count;i++)
{
string[] DBParamtes=strTemp.split(',')
foreach(string strTempA in DBParamtes)
{
if(ckbList.Items[i].value==srrTempA)ckbList.Items[i].checked=true;
}
}
CheckBoxListBind(ref ckBList,false);//****默认选择你需的项哈
for(int i=9;i<ckbList.Items.Count;i++)
{
string[] DBParamtes=strTemp.split(',')
foreach(string strTempA in DBParamtes)
{
if(ckbList.Items[i].value==srrTempA)ckbList.Items[i].checked=true;
}
}
解决方案 »
- MVC中细节问题
- 用asp.net实现文件下载到指定目录,而不弹出对话框????
- 用ITextSharp将GridView的内容导出到PDF时,如何能够让列根据数据来自动调整列宽?
- 求一个用VS2005做的无刷新DropDownList联动
- ExcelHelper (Asp.net操作Excel表格) 有没有 for Excel 2003的版本?
- 关于Response.Write输出格式的求助,如何将输出的内容在页面的底部,而不是页面默认的顶部
- [求助]???关于tag标签的数据库结构设计???
- 打印网页时不打印标题和URL以及当前时间
- datalist控件如何居中显示数据啊
- 这两个连接字符串区别在哪?为什么效果不同?
- ASP.NET 2.0中TreeView不让选择节点呀!请高手回答一下!谢谢!
- 高手来看看 小菜遇到了问题
的选项名是从数据库去的
比如
[] last 50
[] last 100
[] last 150
这个是从数据字典表中棒定的
但是
对应的每一个合同,他对应的有个字符传,(如)1,3,
那么选中第一项和第二项
{
private DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
getContract();
}
}
public void getContract()
{
string strconnt = "server=server01;database=cisco;uid=sa;pwd=sql";
SqlConnection con = new SqlConnection(strconnt);
con.Open();
SqlCommand cmd = new SqlCommand("CIS_GetAllReportsByCustomer", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Cust_ID", "cu000002");
SqlDataAdapter da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
Gridview1.DataSource = ds;
Gridview1.DataBind();
////string str = ds.Tables[0].Rows[0]["Report_No"].ToString();
//////CheckBoxList list = Gridview1.FindControl("chkReports") as CheckBoxList;
//////string[] strarr = str.Split(',');
//////for (int i = 0; i < list.Items.Count; i++)
//////{
////// for (int j = 0; j < strarr.Length; j++)
////// {
////// if (list.Items[i].Value == strarr[j])
////// {
////// list.Items[i].Selected = true;
////// }
////// }
//////}
}
public DataTable bindData()
{
return new BLCommon().BLGetResportReference().Table;
} protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType ==DataControlRowType.DataRow)
{
CheckBoxList list = new CheckBoxList();
list = e.Row.FindControl("chkReports") as CheckBoxList;
Label lbl = new Label();
lbl = e.Row.FindControl("lblID") as Label; string str = lbl.Text; //ds.Tables[0].Rows[0]["Report_No"].ToString();
string[] strarr = str.Split(',');
for (int i = 0; i < list.Items.Count; i++)
{
for (int j = 0; j < strarr.Length; j++)
{
if (list.Items[i].Value == strarr[j])
{
list.Items[i].Selected = true;
}
}
}
}
}
}