这是我的gridview页面。
style="top: 315px; left: 47px; position: absolute; height: 121px; width: 979px"
AllowPaging="True" BackColor="White" BorderColor="#CC9966" BorderStyle="None"
BorderWidth="1px">
<Columns>
<asp:BoundField DataField="DepartureTime" HeaderText="DepartureTime"
SortExpression="DepartureTime" />
<asp:BoundField DataField="Comments" HeaderText="Comments"
SortExpression="Comments" />
<asp:BoundField DataField="Time" HeaderText="Time"
SortExpression="Time" />
<asp:BoundField DataField="Data" HeaderText="Data"
SortExpression="Data" />
<asp:BoundField DataField="Locations" HeaderText="Location"
SortExpression="Location" />
<asp:BoundField DataField="Destination" HeaderText="Destination"
SortExpression="Destination" />
<asp:BoundField DataField="TrackingID" HeaderText="TrackingID"
SortExpression="TrackingID" />
<asp:BoundField DataField="Shipper" HeaderText="Shipper"
SortExpression="Shipper" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:BoundField DataField="Receiver" HeaderText="Receiver" SortExpression="Receiver" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:BoundField DataField="Origin" HeaderText="Origin"
SortExpression="Origin" />
<asp:BoundField DataField="ReceiverAddres" HeaderText="ReceiverAddres"
SortExpression="ReceiverAddres" />
</Columns>
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<SortedAscendingCellStyle BackColor="#FEFCEB" />
<SortedAscendingHeaderStyle BackColor="#AF0101" />
<SortedDescendingCellStyle BackColor="#F6F0C0" />
<SortedDescendingHeaderStyle BackColor="#7E0000" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:sqlConStr %>"
SelectCommand="SELECT * FROM [trackingInfo] WHERE ([TrackingID] = @TrackingID)">
<SelectParameters>
<asp:FormParameter FormField="trackingnumber" Name="TrackingID" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
这是我的表单页面。
当我创建的是使用visual studio和sql management studio时,这项工作很好 但当我把它托管到我的Windows网站托管并使用我的控制面板中的数据库,其中webadmin是管理软件。此gridview停止工作,并显示此错误消息“未找到 在此服务器上找不到请求的文档。
mydomin.org.uk上的Web服务器“ 我已经在web.config文件中检查了我的connectionstring,这是没有问题的。 请帮助我,因为我已经把所有理想都放在了这个但是没有用。 提前谢谢。
答案 0 :(得分:0)
请在web.config文件中管理您的连接字符串......
<ConnectionStrings>
<!--Live--><add name="ConnectionString" connectionString="server=64.5.122.60;user id=user123;password=password;database=databaseName;port=9293" providerName="MySql.Data.MySqlClient"/>
<!--Local--><add name="ConnectionString" connectionString="server=localhost;user id=root;password=root;database=databaseName;port=3306" providerName="MySql.Data.MySqlClient"/>
</ConnectionStrings>
希望有所帮助
答案 1 :(得分:0)
protected void Page_Load(object sender, EventArgs e)
{
BindGrid();
}
private void BindGrid()
{
MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["sqlConStr"].ConnectionString);
string sql = "Select * from tableName;";
MySqlCommand command = new MySqlCommand(sql,connection);
command.CommandType = CommandType.Text;
MySqlDataAdapter adapter = new MySqlDataAdapter(command);
DataTable datatable = new DataTable();
adapter.Fill(datatable);
GridView1.DataSource=datatable;
GridView1.DataBind();
}
这会手动绑定你的网格...希望这会再次帮助你...谢谢