vs2005 GrdiView 的小问题 50分 速度拿去。。。

YSEE 2006-04-24 08:20:45
问题1:
无法显示Microsoft文档资源管理器,因为指定的帮助集合"ms-help://MS.MSDNQTR.v80.chs"无效
这就是错误呢,
请问这是什么原因呢,要怎么解决呢?,谢谢
重装也没用。
问题2:
<asp:GridView ID="GridView1" runat="server" Height="10px" Width="126px" AutoGenerateColumns="False">
<PagerTemplate>
<asp:Image ID="Image1" runat="server" Height="8px" Width="8px" ImageUrl="../../images/15x15.gif" />
<asp:Label ID="LB1" runat="server" Height="8px" Width="8px" Text='<%# Eval("name") %>'></asp:Label>
</PagerTemplate>
</asp:GridView>

protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource = ysee.Product.GetCategoryList();
GridView1.DataBind();
}
ysee.Product.GetCategoryList()出的数据是
name
1
2
3

我那步错了?怎么帮定不了数据
在vs2003里都会用。MSDN2005又用不了。只有发贴了。
在vs2003里
private void DataGrid1_PageIndexChanged(object source,System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataBind();
}
2005里不用了??怎么办呀。
...全文
147 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
antiking 2006-04-24
  • 打赏
  • 举报
回复
重装吧.还是一样问题的话你的安装软件有问题...
YSEE 2006-04-24
  • 打赏
  • 举报
回复
第2个问题是列的问题。哈哈。

可第一个问题是不是非要重装VS2005呢?
antiking 2006-04-24
  • 打赏
  • 举报
回复
DataKeys="你的字段"
YSEE 2006-04-24
  • 打赏
  • 举报
回复
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource = ysee.Product.GetCategoryList();
GridView1.DataBind();
}
当AutoGenerateColumns="True"时页面上显示
name
1
2
3
当AutoGenerateColumns="False"时页面上没有显示

页面是得到了数据,但帮定步凑有错。

和VS2003比。好想少了个索引的问题。但不知道怎么做
quou2002 2006-04-24
  • 打赏
  • 举报
回复
1、msdn版本可能不对;
2、你的GridView的AutoGenerateColumns="False",即非自动生成列,而你代码声明里没有声明列,当然什么都没有显示的。
例如下面的<Columns>....</Columns>就是在AutoGenerateColumns="False"的情况下显示声明的列。
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="DepartmentId" DataSourceID="SqlDataSource1" PageSize="3">
<Columns>
<asp:BoundField DataField="DepartmentId" HeaderText="DepartmentId" ReadOnly="True"
SortExpression="DepartmentId" />
<asp:BoundField DataField="DepartName" HeaderText="DepartName" SortExpression="DepartName" />
</Columns>
</asp:GridView>
因为你不是使用数据源控件自动绑定,可以设置自动生成列AutoGenerateColumns="True",试试看。

另外,我看见你欲自定义分页界面(设置 PagerTemplate 属性后,该属性重写内置页导航行用户界面。)通常,将按钮控件添加到页导航模板以执行分页操作。单击 CommandName 属性设置为“Page”的按钮控件时,GridView 控件会执行分页操作。按钮的 CommandArgument 属性确定要执行的分页操作的类型。下表列出了 GridView 控件支持的命令参数值。

“CommandArgument值”---“说明”
“Next”- 导航至下一页。
“Prev”- 导航至上一页。
“First”- 导航至第一页。
“Last”- 导航至最后一页。
整数值 - 导航至指定页码。

可能你不方便查msdn,贴段msdn中的示例:
下面的代码示例演示如何创建一个允许用户使用 DropDownList 控件在 GridView 控件中进行导航的自定义页导航模板。
<%@ Page language="C#" %>

<script runat="server">

void PageDropDownList_SelectedIndexChanged(Object sender, EventArgs e)
{

// Retrieve the pager row.
GridViewRow pagerRow = CustomersGridView.BottomPagerRow;

// Retrieve the PageDropDownList DropDownList from the bottom pager row.
DropDownList pageList = (DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList");

// Set the PageIndex property to display that page selected by the user.
CustomersGridView.PageIndex = pageList.SelectedIndex;

}

void CustomersGridView_DataBound(Object sender, EventArgs e)
{

// Retrieve the pager row.
GridViewRow pagerRow = CustomersGridView.BottomPagerRow;

// Retrieve the DropDownList and Label controls from the row.
DropDownList pageList = (DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList");
Label pageLabel = (Label)pagerRow.Cells[0].FindControl("CurrentPageLabel");

if(pageList != null)
{

// Create the values for the DropDownList control based on
// the total number of pages required to display the data
// source.
for(int i=0; i<CustomersGridView.PageCount; i++)
{

// Create a ListItem object to represent a page.
int pageNumber = i + 1;
ListItem item = new ListItem(pageNumber.ToString());

// If the ListItem object matches the currently selected
// page, flag the ListItem object as being selected. Because
// the DropDownList control is recreated each time the pager
// row gets created, this will persist the selected item in
// the DropDownList control.
if(i==CustomersGridView.PageIndex)
{
item.Selected = true;
}

// Add the ListItem object to the Items collection of the
// DropDownList.
pageList.Items.Add(item);

}

}

if(pageLabel != null)
{

// Calculate the current page number.
int currentPage = CustomersGridView.PageIndex + 1;

// Update the Label control with the current page information.
pageLabel.Text = "Page " + currentPage.ToString() +
" of " + CustomersGridView.PageCount.ToString();

}

}

</script>

<html>
<body>
<form runat="server">

<h3>GridView PagerTemplate Example</h3>

<asp:gridview id="CustomersGridView"
datasourceid="CustomersSqlDataSource"
autogeneratecolumns="true"
allowpaging="true"
ondatabound="CustomersGridView_DataBound"
runat="server">

<pagerstyle forecolor="Blue"
backcolor="LightBlue"/>

<pagertemplate>

<table width="100%">
<tr>
<td width="70%">

<asp:label id="MessageLabel"
forecolor="Blue"
text="Select a page:"
runat="server"/>
<asp:dropdownlist id="PageDropDownList"
autopostback="true"
onselectedindexchanged="PageDropDownList_SelectedIndexChanged"
runat="server"/>

</td>

<td width="70%" align="right">

<asp:label id="CurrentPageLabel"
forecolor="Blue"
runat="server"/>

</td>

</tr>
</table>

</pagertemplate>

</asp:gridview>

<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the Northwind sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:sqldatasource id="CustomersSqlDataSource"
selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]"
connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>"
runat="server">
</asp:sqldatasource>

</form>
</body>
</html>










==== 我的邮箱:quou2002@tom.com
~~~~ 我的Blog:http://blog.csdn.net/quou2002
xcz1943 2006-04-24
  • 打赏
  • 举报
回复
chagel(Mike in Shanghai)
在很多情况下,用那些datasource绑定是无法完成任务的。不相信你自己试试。
gridview使用一切正常。看看是不是你的连接出错。
YSEE 2006-04-24
  • 打赏
  • 举报
回复
返回一个DataSet
triffang 2006-04-24
  • 打赏
  • 举报
回复
反正我用的时候是没有什么问题
triffang 2006-04-24
  • 打赏
  • 举报
回复
ysee.Product.GetCategoryList()
不知道你这个方法是返回什么的?
一个DataSet?一个集合?
下面的是改成这个了
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{

}
chagel 2006-04-24
  • 打赏
  • 举报
回复
aspnet2不推荐直接绑定,参考
http://www.asp.net/QuickStart/aspnet/doc/ctrlref/data/gridview.aspx

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧