日期:2014-05-18  浏览次数:20494 次

DataGrid分页存储问题
我有一个datagrid控件在页面中,并且有一个dropdownlist控件,允许分页。现在想一次性选择多面后,提交给数据库。不知道怎么做可把多页的选择结果存入数据库?谢谢,请帮忙解决。(要c#语言的)

------解决方案--------------------
用row_number()函数
例如: @startIndex int, 
@pageSize int
AS
begin
WITH TitileList AS (
SELECT ROW_NUMBER() OVER (ORDER BY AddTime DESC) AS ROW,ID,TitleName,IfRecommend,LanguageWord,AddTime from TitleList where IfRecommend='否')

SELECT ID,TitleName,IfRecommend,LanguageWord,AddTime FROM TitileList WHERE Row between @startIndex and @startIndex+@pageSize-1
end


------解决方案--------------------
参考这篇文章,你举一反三一下就可以了,完全符合你要求

http://www.cnblogs.com/vegaslee/archive/2008/07/29/1255480.html
------解决方案--------------------
尤其是这一段

protected void btnOK_Click(object sender, EventArgs e)
{
string strUID = "";
for (int i = 0; i < grdPre.Rows.Count; i++)
{
if (((CheckBox)grdPre.Rows[i].Cells[0].FindControl("item")).Checked == true)
{
//这下面是写的label,你的无非是用FindControl找到你的dropdownlist的selectitem.value
string strD = ((Label)grdPre.Rows[0].Cells[10].FindControl("Label1")).Text;
string strM = ((Label)grdPre.Rows[0].Cells[11].FindControl("Label2")).Text;
string strSql = "select max(utilizeID) from t_bputilize";
DataSet ds = db.GetDataSet(strSql);
int intU = int.Parse(ds.Tables[0].Rows[0][0].ToString())+1;

strSql = "insert into t_bputilize(utilizeID,MoelGroupID,DetailID) values('"+intU+"','" + strM + "','" + strD + "')";
db.ExecuteNonQuery(strSql);

strUID = strUID+intU.ToString()+";";

}
}
Session["utilizeID"] = strUID;
Response.Write("<script>window.opener.refresh();window.close()</script>");
}
------解决方案--------------------
我汗,你还在问我怎么写入数据库,上面已经写了啊

strSql = "insert into t_bputilize(utilizeID,MoelGroupID,DetailID) values('"+intU+"','" + strM + "','" + strD + "')";
 db.ExecuteNonQuery(strSql);
------解决方案--------------------
StateView["delid"]="1,2,3,4,5"..