高分请教:DataList 显示详细信息 不让原来信息消失 我想单击DataList中按钮显示详细信息,且原信息不消失,就是在原信息下在显示详细信息(两个信息都能看见)能实现吗?怎么实现?请写清楚点,刚学~!能力有限,只能给这么多分了,请见谅!谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 加javascript啊.在模板里用以该行ID命名的DIV先隐藏内容.然后以JAVASCRIPT操作之. 可以在DataList下面用一个Panel(里面放显示详细信息的控件,比如label,textbox都行),先让它隐藏,当点击DataList某一行时激发,显示这个Panel,并且把点击当前行的某个值传进去,然后去数据库中找出与该值相关的详细信息即可 前台<asp:dropdownlist id="DDLRole" runat="server"></asp:dropdownlist><asp:datalist id="DlistRole" ><SelectedItemTemplate><%#DataBinder.Eval(Container.DataItem,"description")%></SelectedItemTemplate><ItemTemplate><asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox><%#DataBinder.Eval(Container.DataItem,"authorname")%><asp:Button id="Button1" runat="server" Height="20px" Width="32px" BorderStyle="None" CausesValidation="False" CommandName="Button1" Text="说明"></asp:Button></ItemTemplate></asp:datalist>后台private void DlistRole_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e) { if(e.CommandName=="Button1") { this.DlistRole.SelectedIndex=e.Item.ItemIndex; DB.Service1 obj=new WebSafeSupervise.DB.Service1(); DataSet ds=new DataSet(); ds=obj.Show(); this.DlistRole.DataSource=ds; this.DlistRole.DataBind(); } }To:drk928(一起看斜阳) 你说的以该行ID命名的DIV,该行ID指的是什么啊,在我这个程序中是哪个啊?To:job_2006(初学.net)当点击DataList某一行时激发,我怎么能得到我点击是那一行,用什么事件可以触发?谢谢大家支持,请多多指教! TO:nina36633640(人儿)可以在DataList的ItemCommand事件里写,这样的话,比如你用了一个模板列,里面放了一个linbutton,linbutton的CommandName=dd,则你可以写:if(e.CommandName=="dd"){Panel111.Visble=true;ssss(e.Item.Cells[0].Text.Trim());//为一个方法,里面的e.Item.Cells[0].Text.Trim()就是你点击的那个e.Item.Cells[0].Text.Trim(),也就是你把唯一的主ID号绑定到linkbutton的text应该就行了Text='=<%#DataBinder.Eval(Container.DataItem,"??????")%>'cells[0/1/2/3]这个你应该知道吧?????}当点击DataList某一行时激发,我怎么能得到我点击是那一行::: 1. 在一个页面中body之间加入(比如down.aspx)<script language=javascript>ie4=(document.all)?true:false;ns4=(document.layers)?true:false;function toExit(){var args=toExit.arguments;var visible=args[0];if(ns4){ theObj=eval("document.layers[\'"+args[1]+"\']"); if(theObj)theObj.visibility=visible; }else if(ie4){ if(visible=='show')visible='visible'; if(visible=='hide')visible='hidden'; theObj=eval("document.all[\'"+args[1]+"\']"); if(theObj)theObj.style.visibility=visible; }}</script>2.做一个用户控件在里面加入层,不要设置左,上,(这些在Dreamweaver里完成比较方便)<div id='A(加个A是因为不能用数字做id)<%这里帮定你数据库中的id%>' //关键在这里style="HEIGHT: 80px; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: hidden; WIDTH: 180px; Z-INDEX: 1"> <table bgcolor=#666666 border=1 cellpadding=0 cellspacing=0 height=80 width=180> <tbody> <tr> <td height=65 width="100%"> <table border=0 cellpadding=0 cellspacing=0 height=80 width="99%"> <tbody> <tr> <td height=57><%这里帮定你要显示的内容%></td> </tr> <tr align="center"> <td height=23 width="100%"><a href="javascript:toExit('hide','A<%帮定你的id%>')">关闭此窗口</a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </div>3.在控件中加入显示层的链接 <a href="javascript:toExit('show','A<%这里帮定同上,也就是数据库中的id%>')">打开隐藏层</a>4.在down.aspx 中加入一个datalist,帮定数据源其中包含上面的id,在模版列中加入这个控件。5.看看效果吧,那个层可以用DW修饰一下。 用div了.控制div的display属性.<div> <table> 你要显示详细信息的内容 ... </table></div> To:luby(轻疯 [就让这一切随疯而去吧,随风而去吧。]) <div id='A(加个A是因为不能用数字做id)<%这里帮定你数据库中的id%>' //关键在这里这里的数据库中的id指的是什么,数据库名?表名?还是字段名啊?也是<%#DataBinder.Eval(Container.DataItem,"。。")%>语句吗?不用建立用户控件不行吗?直接在原.aspx中加入div可以吗?To:job_2006(初学.net)Datalist中没有cell属性。 求救,如何在浏览器中直接打开OFFICE文档 求助关于加密解密的问题!! --- 几个DataSet的操作问题 --- 我想做一个网站,其中后台分成二个项目,可不知项目之间应如何通讯。(session还是cookies或是别的?谢谢!!! 页面变背景色问题 ASP.NET页面提交回传后保存表单内容 求划uml 图的那个软件下载地址 帮帮忙~简单~急 程序员加班大调查,大家平常加班都加到晚上几点,第二天又什么时候上班吗? start执行应用程序,能够通过编译,为什么打开浏览器浏览时出错? 大哥有这么做过得么???????? 这样的CSS怎么设置?
<asp:dropdownlist id="DDLRole" runat="server"></asp:dropdownlist>
<asp:datalist id="DlistRole" >
<SelectedItemTemplate>
<%#DataBinder.Eval(Container.DataItem,"description")%>
</SelectedItemTemplate>
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
<%#DataBinder.Eval(Container.DataItem,"authorname")%>
<asp:Button id="Button1" runat="server" Height="20px" Width="32px" BorderStyle="None" CausesValidation="False" CommandName="Button1" Text="说明"></asp:Button>
</ItemTemplate>
</asp:datalist>
后台
private void DlistRole_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
if(e.CommandName=="Button1")
{
this.DlistRole.SelectedIndex=e.Item.ItemIndex;
DB.Service1 obj=new WebSafeSupervise.DB.Service1();
DataSet ds=new DataSet();
ds=obj.Show();
this.DlistRole.DataSource=ds;
this.DlistRole.DataBind(); }
}
To:drk928(一起看斜阳)
你说的以该行ID命名的DIV,该行ID指的是什么啊,在我这个程序中是哪个啊?To:job_2006(初学.net)
当点击DataList某一行时激发,我怎么能得到我点击是那一行,用什么事件可以触发?谢谢大家支持,请多多指教!
可以在DataList的ItemCommand事件里写,这样的话,比如你用了一个模板列,里面放了一个linbutton,linbutton的CommandName=dd,则你可以写:
if(e.CommandName=="dd")
{
Panel111.Visble=true;
ssss(e.Item.Cells[0].Text.Trim());//为一个方法,里面的e.Item.Cells[0].Text.Trim()就是你点击的那个e.Item.Cells[0].Text.Trim(),也就是你把唯一的主ID号绑定到linkbutton的text应该就行了Text='=<%#DataBinder.Eval(Container.DataItem,"??????")%>'
cells[0/1/2/3]这个你应该知道吧?????
}
当点击DataList某一行时激发,我怎么能得到我点击是那一行:::
<script language=javascript>
ie4=(document.all)?true:false;
ns4=(document.layers)?true:false;function toExit(){
var args=toExit.arguments;
var visible=args[0];
if(ns4){
theObj=eval("document.layers[\'"+args[1]+"\']");
if(theObj)theObj.visibility=visible;
}
else if(ie4){
if(visible=='show')visible='visible';
if(visible=='hide')visible='hidden';
theObj=eval("document.all[\'"+args[1]+"\']");
if(theObj)theObj.style.visibility=visible;
}}</script>2.做一个用户控件在里面加入层,不要设置左,上,(这些在Dreamweaver里完成比较方便)<div id='A(加个A是因为不能用数字做id)<%这里帮定你数据库中的id%>' //关键在这里
style="HEIGHT: 80px; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: hidden; WIDTH: 180px; Z-INDEX: 1">
<table bgcolor=#666666 border=1 cellpadding=0 cellspacing=0 height=80
width=180>
<tbody>
<tr>
<td height=65 width="100%">
<table border=0 cellpadding=0 cellspacing=0 height=80 width="99%">
<tbody>
<tr>
<td height=57>
<%这里帮定你要显示的内容%>
</td>
</tr>
<tr align="center">
<td height=23 width="100%">
<a href="javascript:toExit('hide','A<%帮定你的id%>')">关闭此窗口</a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
3.在控件中加入显示层的链接
<a href="javascript:toExit('show','A<%这里帮定同上,也就是数据库中的id%>')">打开隐藏层</a>
4.在down.aspx 中加入一个datalist,帮定数据源其中包含上面的id,在模版列中加入这个控件。
5.看看效果吧,那个层可以用DW修饰一下。
<div>
<table>
你要显示详细信息的内容 ...
</table>
</div>
<div id='A(加个A是因为不能用数字做id)<%这里帮定你数据库中的id%>' //关键在这里
这里的数据库中的id指的是什么,数据库名?表名?还是字段名啊?也是<%#DataBinder.Eval(Container.DataItem,"。。")%>语句吗?
不用建立用户控件不行吗?直接在原.aspx中加入div可以吗?To:job_2006(初学.net)
Datalist中没有cell属性。