小弟我在使用dropdownlist绑定数据后设置的它DataTextField和DataValueField如下:
this.ddlSmallClass.DataTextField="SmallClassName";
this.ddlSmallClass.DataValueField="SmallClassID"(数据库中表的主键);
然后当选择下拉菜单的某一选项时把DataValueField的值传到另一页面 但是所接收到的DataValueField都为dropdownlist的第一项的值 就是说所接收到的值都是一样的. 兄弟们帮忙解解
还有就是在用datagrid自带自动分页时:比如说有2页,当我把第2页的内容中的最后一天删除的时候就会出现错误 提示页的索引值必须大于等于0,怎么解决?
谢谢兄弟们帮忙啊~~~
this.ddlSmallClass.DataTextField="SmallClassName";
this.ddlSmallClass.DataValueField="SmallClassID"(数据库中表的主键);
然后当选择下拉菜单的某一选项时把DataValueField的值传到另一页面 但是所接收到的DataValueField都为dropdownlist的第一项的值 就是说所接收到的值都是一样的. 兄弟们帮忙解解
还有就是在用datagrid自带自动分页时:比如说有2页,当我把第2页的内容中的最后一天删除的时候就会出现错误 提示页的索引值必须大于等于0,怎么解决?
谢谢兄弟们帮忙啊~~~
DataSourceID="ObjectDataSource1" AutoPostBack="True"
DataTextField="CategoryName" DataValueField="CategoryID">
</asp:DropDownList><asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetCategories" TypeName="CategoriesBLL"></asp:ObjectDataSource>protected void Selection_Change(Object sender, EventArgs e)
{
Session["StoreCategoryID"] = DropDownList1.SelectedItem.Value; Response.Redirect("~/ProductByDropdownlist.aspx");
}
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID"
DataSourceID="ObjectDataSource1">
<
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetProductsByCategoryID"
TypeName="ProductsBLL">
<SelectParameters>
<asp:SessionParameter DefaultValue="0" Name="categoryID" SessionField="StoreCategoryID"
Type="Int32" />
</SelectParameters>
if(!IsPostBack)
{
//将与dropdownlist数据绑定相关的代码都放到这里
}
2.在执行删除之前加上以下语句:
if(this.datagrid.Items.Count == 1)
{
if(this.datagrid.CurrentPageIndex != 0)
{
this.datagrid.CurrentPageIndex = this.datagrid.CurrentPageIndex - 1;
}
}
//执行删除操作
作用就是在删除之前先判断当前页是不是只剩下一条记录了,如果是则将datagrid的"当前页"设为它的"上一页"