我有一个Gridview2
,我想用表“contact
”填充数据。
我这样做但现在我想要Gridview
中的每个方框都有一个单选按钮。
我尝试了很多,但我找不到合适的解决方案。
有人有想法吗?
这是我方法的代码:
protected void load_data()
{
String str1 = Label1.Text;
String str2 = Label2.Text;
try
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=ic-webdev;Initial Catalog=intracall;User ID=sa;Password=xs4intracall";
con.Open();
SqlDataAdapter ada = new SqlDataAdapter("SELECT [id],[firstname], [lastname],[street],[zipcode], [city],[customerNumber],[salutation], [company],[departement],[telephone] FROM contact WHERE SOUNDEX(firstname)=SOUNDEX('" + str1 + "') AND SOUNDEX(lastname)=SOUNDEX('" + str2 + "')", con);
DataTable dt = new DataTable();
ada.Fill(dt);
GridView2.DataSource = dt;
GridView2.DataBind();
SetSelectedRecord();
con.Close();
}
catch (Exception) { }
}
这是Gridview2
:
<asp:GridView ID="GridView2" runat="server" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" CellSpacing="4" GridLines="Vertical" Height="160px" OnSelectedIndexChanged="GridView2_SelectedIndexChanged" Width="271px" ForeColor="Black" ShowHeaderWhenEmpty="True" IsPostBack="false">
<AlternatingRowStyle BackColor="White" />
<Columns > </Columns>
</asp:GridView>