请教链接问题
页面上没有出现DataGrid1控件,webconfig是对的代码如下:
protected void Show_DataGrid1()
{
//从文件Web.config中读取连接字符串
string sqldb = ConfigurationSettings.AppSettings["ConnectionString"];
//连接数据库
SqlConnection Conn = new SqlConnection(sqldb);
//定义sql语句
String selsql = "select UserID,UserName,PassWord,Email,Role from tb_User";
//创建SqlDataAdapter对象,调用selsql
SqlDataAdapter myadapter = new SqlDataAdapter(selsql, Conn);
//创建并填充DataSet
DataSet ds = new DataSet();
myadapter.Fill(ds);
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
//关闭Conn
Conn.Close();
} --------------------编程问答-------------------- 什问题 --------------------编程问答-------------------- 页面上啥也没有。。。 --------------------编程问答-------------------- 确保调用了Show_DataGrid1方法。 --------------------编程问答-------------------- 难道这里有错误?
<asp:DataGrid ID="DataGrid1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" BorderColor="Black" ForeColor="#333333"
Height="153px" Width="100%">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditItemStyle BackColor="#2461BF" />
<SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="White" />
<ItemStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundColumn DataField="UserID" HeaderText="用户编码"></asp:BoundColumn>
<asp:BoundColumn DataField="UserName" HeaderText="用户名"></asp:BoundColumn>
<asp:BoundColumn DataField="PassWord" HeaderText="密码"></asp:BoundColumn>
<asp:BoundColumn DataField="Email" HeaderText="Email"></asp:BoundColumn>
<asp:BoundColumn DataField="Role" HeaderText="分校代码"></asp:BoundColumn>
</Columns>
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
</asp:DataGrid>
补充:.NET技术 , C#