西北的天空 西北的天空
关注数: 0 粉丝数: 160 发帖数: 742 关注贴吧数: 13
关于编辑多行datalist的案例! C# <%@ Page Language="C#" Debug="true" %> string[] ClassNameArray = { "大学", "中学", "高中" };//初始化原来的值protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { System.Data.DataRowView drv = (System.Data.DataRowView)e.Row.DataItem; RadioButtonList rbl = (RadioButtonList)e.Row.FindControl("txtGender"); if (rbl != null) { if ((bool)drv["Gender"]) { rbl.Items.FindByText("男").Selected = true; } else { rbl.Items.FindByText("女").Selected = true; } } DropDownList ddl = (DropDownList)e.Row.FindControl("txtClassName"); if (ddl != null) { ddl.Items.FindByText(drv["ClassName"].ToString()).Selected = true; } }}// 初始化项目列表protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { DropDownList ddl = (DropDownList)e.Row.FindControl("txtClassName"); ddl.DataSource = ClassNameArray; ddl.DataBind(); }}//处理提交的数据protected void XianhuiMeng_Click(object sender, EventArgs e){ foreach (GridViewRow gvr in GridView1.Rows) { string tGender = ((RadioButtonList)gvr.FindControl("txtGender")).SelectedValue; SqlDataSource1.UpdateParameters.Add(new Parameter("@Title", TypeCode.String, ((TextBox)gvr.FindControl("txtTitle")).Text)); SqlDataSource1.UpdateParameters.Add(new Parameter("@Gender", TypeCode.Boolean, (tGender == "男" ? "True" : "False"))); SqlDataSource1.UpdateParameters.Add(new Parameter("@ClassName", TypeCode.String, ((DropDownList)gvr.FindControl("txtClassName")).SelectedValue)); SqlDataSource1.UpdateParameters.Add(new Parameter("@id", TypeCode.Int32, GridView1.DataKeys[gvr.DataItemIndex].Value.ToString())); SqlDataSource1.Update(); SqlDataSource1.UpdateParameters.Clear(); } Response.Redirect(Request.UrlReferrer.ToString());} 同时编辑 GridView的 多行 注意:对于SQL Server 数据库,参数名字不加@。另外注意:不同数据库类型和不同的数据源,UpdateCommand="Update [Student] Set Title = @Title,Gender = @Gender,ClassName=@ClassName Where id=@id"写法和SqlDataSource1.UpdateParameters.Add(new Parameter("@Title", TypeCode.String, ((TextBox)gvr.FindControl("txtTitle")).Text)); 的写法会有所区别。
本人的一点体会! 在打2V2时,碰到那些场均18+分,或者命中50%+的SG或PG时,别和他打,先不说你打不过,就算你打的过(和朋友一起配合好),80%的情况下如果比赛开始2分钟内他会退的,我碰到的有很多这样的例子,最少有十几个这样好数据的人在跟我比赛时退了,虽然我不怎么会玩,我PG3分命中从没超过40%,目前是36%,场均10.5分,3.3个助攻,1个帽0.9的抢断。就我这数据他们还打不过我不知道他们的数据是怎么来的,要是天天退的话我就没话说了,这样不知道有什么意义。不过也有不退的汉子,有一次一个SG70%的3分命中场均21分,不过没打多少比赛,他跟我们打,我和我朋友看不过去(我看那数据眼红),于是我和我朋友(他PF)防他一个,不管对面的C,把他打的郁闷死了,说我们不好似人,不过他确实很厉害这样的情况下比赛中还得了9分,4投3中,他问我们为什么要这样,我如实告诉他了,他无语了只说运气不好碰到我们了。其实主要是他速度快是个RMB玩家,买一身装备,本人连背2都没学,全身就花积分买的1000分的衣服(太穷了),防守他还是有点吃亏。 最后在说一下,2V2不要老打3,最主要打成功率,我和我朋友碰到厉害的G了只防3不管了,还能赢大部分比赛,最主要就是有些PF和C只会抢板在篮下空了都不投。我在这里最主要还是鄙视那些看重数据稍微打的不好就退的玩家。
1 下一页