使GridView1显示文本框中输入的随机条数
一个文本框一个按钮一个GridView1一个SqlDataSource1在按钮中输入什么代码使GridView1显示文本框中的随机条数我就写了
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class EExtract : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection cnn = new SqlConnection("Data Source=.;Database=Ex; User id=sa; password=123456");
cnn.Open();
string top = TextBox1.Text;
string sql = "select top " + top + "* from [User] order by newid()";
}
}
求看下求添加补充
textbox
object
string
database
button
------解决方案--------------------非常不错,适合初学者来参考!