使用模版列,设置selectedindex的值
解决方案 »
- 新建网站项目
- 捣蛋的“水晶报表”问题(asp.net),路过的进来看一下。
- 一个网页上传到服务器后非常慢是什么情况?
- .net 自定义数据类型转换问题
- 还是导出excel的问题
- Response.Redirect ("?")传值问题
- 关于<input type="file" id="file1" runat="server" NAME="file1">小问题
- 请大家帮我看看到底是哪里有错呀,小弟不才调了很久就是不行呀,急死了!。。。
- DataGrid 中一列("do")是bool值的,如何使当("do")字段值是True时,DataGrid 中的("do")列显示一块图片,False不显示?
- 如何使DropDownList的autopostback属性为false,但是能激发selectedindexchanged
- 短信开发
- (高分相送)有几个关于datagrid的问提,messagebox,checkbox(vbscript)
<asp:DropDownList id=DropDownList1 runat="server" Width="101px" SelectedIndex='<%# DataBinder.Eval(Container, "DataItem.OPERATOR_CLASS").ToString()=="A"? 0:1 %>'>
<asp:ListItem Value="A">管理员</asp:ListItem>
<asp:ListItem Value="O">操作员</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<HeaderStyle Width="50px"></HeaderStyle>
<ItemTemplate>
<asp:Label id=Label7 runat="server" Width="72px" Height="6px" Text='<%# DataBinder.Eval(Container.DataItem, "Principal") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList id=DropDownList3 runat="server" Width="80px" Height="23px" DataValueField="Name" DataTextField="Name" DataSource="<%# WorkManDataBind() %>">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>这是我的html下面看到的代码。请 kinglht(爱新觉罗至尊宝) ( )兄。。帮忙啊:)
<EditItemTemplate>
<asp:DropDownList id=DropDownList3 runat="server" Width="80px" Height="23px" DataValueField="Name" DataTextField="Name" DataSource="<%# WorkManDataBind() %>">
</asp:DropDownList>
</EditItemTemplate>
改成
<EditItemTemplate>
<asp:DropDownList id="DropDownList1" runat="server" Width="89px" SelectedIndex='<%# DataBinder.Eval(Container, "DataItem.布尔值").ToString()=="True"? 0:1 %>'>
<asp:ListItem Value="1">真</asp:ListItem>
<asp:ListItem Value="0">假</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
我只是举个例子,我的DropDownList只有两项(真假),你可以根据你自己的数据改改!希望对你有帮助!!
when you clicked you "edit" button ,you can get you selectitemindex,and you can get you dropdownlist text(or value) ,save it in you session.
when you bound you dropdownlist ,you can use the session'value find the dpl's itemindex.
All of then ,you should write on DG_editcommand event.
when you clicked you "edit" button ,you can get you selectitemindex,and you can get you dropdownlist text(or value) ,save it in you session.
when you bound you dropdownlist ,you can use the session'value find the dpl's itemindex.
All of then ,you should write on DG_editcommand event.
我试过了。。在editcommand事件里跟本就无法得到在模板列里edit模式
下的DropDownList的selecitemindex..如果使用
e.item.cell[8].findcontrol("DropDownList1")就是出现对象没有引用
到实例的错误。。给我的感觉就是在editcommand事件没有执行完毕的话
datagrid的每一个列还都没有变成edit的模式。也无法得到在edit模式下
的DropDownList
谢谢你热心的帮助我我已经找到了解决的办法:)
通过给SelectIndex返回一个值。就像给Datasource返回一个值一样。
就可以定位到原来的值上:)