gridview模版列怎么进行数据绑定问题。菜鸟在线等
在formload中生成了一个dataset,gridview的数据源为dataset,gridview的每一列都是texttbox模版列,怎么给每个模版列列绑定dataset的数据?? --------------------编程问答-------------------- Eval("***") --------------------编程问答-------------------- <%@ Page Language="VB" %><%@ Import Namespace ="system.data" %>
<%@ Import Namespace ="system.data.oledb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Dim dv As DataView
Dim da As OleDbDataAdapter
Dim ds As New DataSet()
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strsql As String
strsql = "select * from pay "
Dim cn As OleDbConnection
cn = New OleDbConnection()
cn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("pmsdbcon").ToString()
cn.Open()
da = New OleDbDataAdapter(strsql, cn)
da.Fill(ds, "fukuan")
GridView2.DataSource = ds
GridView2.DataBind()
'GridView1.DataSource = ds
'GridView1.DataBind()
End Sub
Protected Sub GridView1_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
】】】】页面代码
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server" onload="form1_Load">
<div>
<br />
<br />
<br />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Style="position: relative" OnDataBinding="GridView1_DataBinding" OnDataBound="GridView1_DataBound">
<Columns>
<asp:TemplateField HeaderText="请选择">
<ControlStyle Font-Size="Smaller" />
<ItemTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" Style="position: relative" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="id">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Style="position: relative"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="项目名称">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Style="position: relative" Text="Label"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="工程内容">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Style="position: relative"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="合同名称">
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Style="position: relative"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="施工单位">
<ItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Style="position: relative"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="付款金额">
<ItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Style="position: relative"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="付款时间">
<ItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Style="position: relative"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="经办人">
<ItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" Style="position: relative"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="备注">
<ItemTemplate>
<asp:TextBox ID="TextBox7" runat="server" Style="position: relative"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Style="position: relative" />
</EmptyDataTemplate>
</asp:GridView>
</div>
<asp:GridView ID="GridView2" runat="server" Style="position: relative">
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/pmsdb.mdb"
SelectCommand="SELECT [id] FROM [pay]"></asp:AccessDataSource>
</form>
</body>
</html>
设有模版列的gridview没有数据显示 --------------------编程问答-------------------- deng a --------------------编程问答-------------------- KDDDDDDDDD --------------------编程问答-------------------- 你在每个模版列(<ItemTemplate>)中没有绑定数据啊。
可以使用<%# Eval("数据库中的列标题") %>进行数据绑定。
CheckBox可以使用<asp:CheckBoxField>实现。 --------------------编程问答-------------------- 你的模版列都没有绑定数据.. --------------------编程问答-------------------- 没有啊,不知道用dataset怎么绑定 --------------------编程问答-------------------- 绑不了,,,就得用SqlDataSource才行,,好像是... --------------------编程问答-------------------- <asp:Label ID= "Label2 " runat= "server " Style= "position: relative " Text= "<%# Eval("数据原字段名")%>">
</asp:Label>
补充:.NET技术 , ASP.NET