GridView的多数据查询
前台代码
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="None" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit" >
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<Columns >
<asp:BoundField DataField="id" HeaderText="用户ID" ReadOnly="True" />
<asp:BoundField DataField="name" HeaderText="用户姓名" ReadOnly="true" />
<asp:BoundField DataField="tel" HeaderText="联系方式" ReadOnly="true" />
<asp:BoundField DataField="yw" HeaderText="业务情况" />
<asp:CommandField HeaderText="选择" ShowSelectButton="True" />
<asp:CommandField HeaderText="编辑" ShowEditButton="True" />
<asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
</Columns >
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView >
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>aa</asp:ListItem>
<asp:ListItem>bb</asp:ListItem>
</asp:DropDownList>
后台代码
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default3 : System.Web.UI.Page
{
SqlConnection sqlcon;
SqlCommand sqlcom;
string strCon = "Data Source=.\\SQLEXPRESS;AttachDbFilename=E:\\业务\\App_Data\\yw.mdf;Integrated Security=True;User Instance=True";
protected void Page_Load(object sender, EventArgs e)
{