ASP.NET中使用数据绑定和数据源控件遇到问题
protectedvoidRadioButtonList1_SelectIndexChanged(objectsender,EventArgse){stringstr="...
protected void RadioButtonList1_SelectIndexChanged(object sender, EventArgs e)
{
string str = "Data Source=.;Database=BookStor;Integrated Security=True";
string text = "+RadioButtonList1.SelectedValue+";
string sql = "select * from BookInfo where Name='"+text+"'";
SqlConnection myConnetion = new SqlConnection(str);
myConnetion.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, myConnetion);
DataSet ds = new DataSet();
sda.Fill(ds, "BookInfo");
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
myConnetion.Close();
}
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" onselectdindexchanged="RadioButtonList1_SelectIndexChanged"
RepeatDirection="Horizontal">
<asp:DataGrid ID="DataGrid1" runat="server" ></asp:DataGrid>
在选中radiobutton控件的时候出现一个选择的数据,但是运行后发现没有出现。 展开
{
string str = "Data Source=.;Database=BookStor;Integrated Security=True";
string text = "+RadioButtonList1.SelectedValue+";
string sql = "select * from BookInfo where Name='"+text+"'";
SqlConnection myConnetion = new SqlConnection(str);
myConnetion.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, myConnetion);
DataSet ds = new DataSet();
sda.Fill(ds, "BookInfo");
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
myConnetion.Close();
}
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" onselectdindexchanged="RadioButtonList1_SelectIndexChanged"
RepeatDirection="Horizontal">
<asp:DataGrid ID="DataGrid1" runat="server" ></asp:DataGrid>
在选中radiobutton控件的时候出现一个选择的数据,但是运行后发现没有出现。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询