我要实现这样的gridview
动态绑定,后台是三张表的关联查询,得到:项目、核心要项、工作要求、达成标准、满分、自我评分(这个用模板列显示),“大区评分”用模板列,待编辑的状态,备注也是,待录入完成后一起提交保存(update)
能实现吗?如何实现?
最好给点相关代码,从DELPHI WINFORM开发刚转ASP.NET。 --------------------编程问答-------------------- http://cn.bing.com/search?q=scott+mitchell+gridview+updateparameters&qs=n&form=QBRE&pq=scott+mitchell+gridview+updateparameters&sc=0-0&sp=-1&sk=
早在4年前,我们就淘汰了asp.net。因为我们选择微软基于企业RIA方式的web开发平台,而asp.net没有将它的控件移植到到ajax所以它就只好被淘汰了。
不过如果你要学asp.net,那么就学这类正规的教程吧。那种只会一点html/javascript就号称自己会asp.net编程的人,其实是不会asp.net的。 --------------------编程问答-------------------- 先回答回答我的问题怎么整啊,堵了老长时间了 --------------------编程问答-------------------- 你的代码呢?
叫你的公司老板来,我直接给他写代码得了。 --------------------编程问答-------------------- 我只要实现主楼说的功能,不要代码也没关系,我就是想问怎么实现这个功能! --------------------编程问答-------------------- 你都用模板列了,那些不都是TextBox了嘛,然后再保存的时候,动态遍历每行,然后保存数据就行了。 --------------------编程问答--------------------
那就是个效果,我数据还没绑定上去呢
怎么手动绑定,然后用主楼的格式? --------------------编程问答-------------------- 普通的数据绑定你不会???下面提供个Repeater方法,纯手写的,根据你实际需要修改,基本思路是这样的
--------------------编程问答-------------------- 数据绑定控件,MS的我只喜欢用Repeater控件。
<asp:GridView ID="gv" runat="server" >
<asp:HeaderTemplate>
<table width="100%">
<tr>
<th>项目</th>
<th>核心要项</th>
<th>工作要求</th>
<th>达成标准</th>
<th>满分</th>
<th>自我评分</th>
<th>大区评分</th>
<th>备注</th>
</tr>
</asp:HeaderTemplate>
<asp:ItemTemplate>
<tr>
<td><asp:Label ID="lb1" runat="server" Text='<%#Eval("项目")%>'></asp:Label></td>
<td><asp:Label ID="lb2" runat="server" Text='<%#Eval("核心要项")%>'></asp:Label></td>
<td><asp:Label ID="lb3" runat="server" Text='<%#Eval("工作要求")%>'></asp:Label></td>
<td><asp:Label ID="lb4" runat="server" Text='<%#Eval("达成标准")%>'></asp:Label></td>
<td><asp:Label ID="lb5" runat="server" Text='<%#Eval("满分")%>'></asp:Label></td>
<td><asp:TextBox ID="tb1" runat="server"></asp:TextBox></td>
<td><asp:TextBox ID="tb2" runat="server"></asp:TextBox></td>
<td><asp:TextBox ID="tb3" runat="server"></asp:TextBox></td>
</tr>
</asp:ItemTemplate>
<asp:FooterTemplate>
</table>
<asp:FooterTemplate>
</asp:GridView>
<asp:Button ID="btnSaveAll" runat="server" Text="全部保存" Click="btnSaveAll_Click"/>
后台cs代码数据绑定
public void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
{
BindRepeater();
}
}
public void BindRepeater()
{
string strSQL = "select 需要绑定的字段列表 from 你的表名";
DataSet ds= XXX.XXX(strSQL); //获取数据集,使用类库,很多方法,不说了
this.rpt.DataSource = ds;
this.rpt.DataBind();
}
//保存全部按钮
public void btnSaveAll_Click(object sender,EventArgs e)
{
foreach( RepeaterItem item in this.Repeater1.Items )
{
Label l1 = (Label)item.FindControl("lb1");
string s1 = l1.Text; //获取项目内容
Label l2 = (Label)item.FindControl("lb1");
string s2 = l2.Text; //获取核心要项内容
Label l3 = (Label)item.FindControl("lb1");
string s3 = l3.Text; //获取工作要求内容
Label l4 = (Label)item.FindControl("lb1");
string s4 = l4.Text; //获取达成目标内容
Label l5 = (Label)item.FindControl("lb1");
string s5 = l5.Text; //获取满分内容
TextBox t1 = (TextBox)item.FindControl("tb1");
string s6 = t1.Text; //获取自我评分内容
TextBox t2 = (TextBox)item.FindControl("tb2");
string s7 = t2.Text; //获取大区评分内容
TextBox t3 = (TextBox)item.FindControl("tb3");
string s8 = t3.Text; //获取备注内容
string strSQL = "insert into 表名(字段类表) values(以上各个值)"; //SQL自己写
XXX.XXX(strSQL); //将数据保存到数据库的方法
}
}
P哥,我们也是用RIA中的Silverlight进行开发的,但是asp.net还在用,我们不敢淘汰它啊 --------------------编程问答-------------------- Refer:
http://www.cnblogs.com/insus/articles/1400150.html
http://www.cnblogs.com/insus/archive/2012/09/22/2698515.html --------------------编程问答-------------------- 不用数据绑定,用update语句就可以。 --------------------编程问答-------------------- 我目前做毕设也是这个问题,我是在前面加checkbox进行控制,然后用循环语句检测checkbox的enabled属性,然后调用ado语句 --------------------编程问答--------------------
谢谢你啊,你的连接解决了我毕设里面一个关于获取GridView行号的问题,非常感谢!我弄了好几天的问题 --------------------编程问答-------------------- 大家都给你方法了。
那我就给你参考。
http://blog.csdn.net/jason_dct/article/details/8497546
补充:.NET技术 , ASP.NET