to bluefish922(思念里的流浪鱼) :我在html里加上SELECTEDINDEX=‘<%# DataBinder.Eval(Container, "DataItem.funLv") %>’会提示参数value超过指定的范围,能告诉我具体怎么做吗?或给段代码参考一下
在DataGrid1_EditCommand里 Dim Lab As Label = CType(e.Item.Cells(X).ControlS(1), Label)‘取显示时LABEL....绑定DropDownListdrop.SelectedIndex = drop.Items.IndexOf((dropI.Items.FindByText(Lab.Text)))’被选中项显示为LABEL中的值
to bluefish922(思念里的流浪鱼):请原谅我一直打扰,我还是有点不明白,我好像找不到CType和ControlS属性,老兄,能不能给个比较詊细的例子说明一下,谢了!
DropDownList drop = (DropDownList)e.Item.FindControl("edit_funLv"); 改为: DropDownList drop = (DropDownList)myGrid.Items[e.Item.ItemIndex].FindControl("edit_funLv");
Dim Lab As Label = CType(e.Item.Cells(X).ControlS(1), Label)‘取显示时LABEL....绑定DropDownListdrop.SelectedIndex = drop.Items.IndexOf((dropI.Items.FindByText(Lab.Text)))’被选中项显示为LABEL中的值
DropDownList drop = (DropDownList)e.Item.FindControl("drop");
drop.SelectedIndex = drop.Items.IndexOf((drop.Items.FindByText(Lab.Text)));另外,不要叫bluefish922为"老兄"
private void myGrid_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
myGrid.EditItemIndex=(int)e.Item.ItemIndex;
dataBind();
Label Lab = (Label)e.Item.FindControl("funLv");
DropDownList drop = (DropDownList)e.Item.FindControl("edit_funLv");
drop.SelectedIndex = drop.Items.IndexOf(drop.Items.FindByText(Lab.Text));
}
改为:
DropDownList drop = (DropDownList)myGrid.Items[e.Item.ItemIndex].FindControl("edit_funLv");