会GridView的,帮帮我! GridView怎么能实现 横向绑定数据。要绑定TextBox ,因为数据需要有修改更新功能。不能用DataTable..有其他解决方案吗?十分感谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 GridView自带修改更新功能的吧 参考http://blog.csdn.net/21aspnet/archive/2007/03/25/1540301.aspx 横向绑定DataList不是很好吗???为啥非要使用GridView呢》微软之所以提供多种控件,就是满足不同需求来的,不同的需求采用合适的控件,而不是的都去采用GridView 是的,现在datalist用的也不是很多,以repeater为主,样式完全按自己的需求来,很灵活。 行转列http://topic.csdn.net/u/20090210/10/25a079f8-1480-48e6-be29-6da3e97cfda3.html GridView的布局已经固定了,你可以用DataList控件,然后在里面写HTML代码,想怎么布局就怎么布局,然后用Eval或DataBinder.Eval方法绑定数据。 这是我做的一个例子 前台:<asp:GridView> <Columns> <asp:TemplateField HeaderText="数量"> <ItemTemplate> <asp:TextBox ID ="textbox1" runat="server" Text='<%#Eval("Quantity")%>'> </asp:TextBox> </ItemTemplate> </asp:TemplateField><asp:ButtonField HeaderText="更新" Text="更新" CommandName="update" /> </Columns></asp:GridView>后台: protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { //获取textbox中要更新的数量 int quantity = Convert.ToInt32(((TextBox)(GridView1.Rows[e.RowIndex].FindControl("textbox1"))).Text); //获取数据库连接字符串 string strconn = ConfigurationManager.ConnectionStrings["connectionStr"].ToString(); //连接数据库 SqlConnection conn = new SqlConnection(strconn); conn.Open(); string strsql = "update CartInfo set Quantity='" + quantity + "' where Name='" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'"; SqlCommand cmd = new SqlCommand(strsql, conn); cmd.ExecuteNonQuery(); conn.Close(); GridView1.EditIndex = -1; //更新后绑定数据 bind(); } 急急,不同权限下,DetailsView的某列插入功能问题 手机发送验证码短信到网站,然后网站发短信给手机 div里如何显示图片 判断网络上一个图片是否存在? 急!!!! 在线等 急求:类似QQ空间中照片批量上传的插件是用什么技术实现的? 任何在 IIS 中将虚拟目录配置为应用程序 关于上传漏洞 HtmlInputFile的一个不解的问题(初学者提问) 如何对发布的网站进行稳定性测试,求救! asp.net如何播放本地视频文件?? 关于绑定值判断的问题
http://blog.csdn.net/21aspnet/archive/2007/03/25/1540301.aspx
微软之所以提供多种控件,就是满足不同需求来的,不同的需求采用合适的控件,而不是的都去采用GridView
http://topic.csdn.net/u/20090210/10/25a079f8-1480-48e6-be29-6da3e97cfda3.html
前台:
<asp:GridView>
<Columns>
<asp:TemplateField HeaderText="数量">
<ItemTemplate>
<asp:TextBox ID ="textbox1" runat="server" Text='<%#Eval("Quantity")%>'>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField><asp:ButtonField HeaderText="更新" Text="更新" CommandName="update" />
</Columns>
</asp:GridView>
后台:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//获取textbox中要更新的数量
int quantity = Convert.ToInt32(((TextBox)(GridView1.Rows[e.RowIndex].FindControl("textbox1"))).Text);
//获取数据库连接字符串
string strconn = ConfigurationManager.ConnectionStrings["connectionStr"].ToString();
//连接数据库
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
string strsql = "update CartInfo set Quantity='" + quantity + "' where Name='"
+ GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
SqlCommand cmd = new SqlCommand(strsql, conn);
cmd.ExecuteNonQuery();
conn.Close();
GridView1.EditIndex = -1;
//更新后绑定数据
bind();
}