<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Show.aspx.cs" Inherits="web.Web.ewsAdmin.aspx.article.Show" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
     <link rel="stylesheet" type="text/css" href="../../skin/css/base.css" />
     <script language="javascript" type="text/javascript">
function viewArc(aid){
if(aid==0) aid = getOneItem();
window.open("archives.asp?aid="+aid+"&action=viewArchives");
}
function editArc(aid){
if(aid==0) aid = getOneItem();
location="archives.asp?aid="+aid+"&action=editArchives";
}
function updateArc(aid){
//var qstr=getCheckboxItem();
//if(aid==0) aid = getOneItem();
//location="archives.asp?aid="+aid+"&action=makeArchives&qstr="+qstr+"";
location="show.aspx"; //?aid="+aid+"&action=makeArchives&qstr="+qstr+"";
}
function checkArc(aid){
var qstr=getCheckboxItem();
if(aid==0) aid = getOneItem();
location="archives.asp?aid="+aid+"&action=checkArchives&qstr="+qstr+"";
}
function moveArc(aid){
var qstr=getCheckboxItem();
if(aid==0) aid = getOneItem();
location="archives.asp?aid="+aid+"&action=moveArchives&qstr="+qstr+"";
}
function adArc(aid){
var qstr=getCheckboxItem();
if(aid==0) aid = getOneItem();
location="archives.asp?aid="+aid+"&action=commendArchives&qstr="+qstr+"";
}
function delArc(aid){
var qstr=getCheckboxItem();
if(aid==0) aid = getOneItem();
location="archives.asp?aid="+aid+"&action=delArchives&qstr="+qstr+"";
}//获得选中文件的文件名
function getCheckboxItem()
{
var allSel="";
if(document.form1.id.value) return document.form1.id.value;
for(i=0;i<document.form1.id.length;i++)
{
if(document.form1.id[i].checked)
{
if(allSel=="")
allSel=document.form1.id[i].value;
else
allSel=allSel+"`"+document.form1.id[i].value;
}
}
return allSel;
}//获得选中其中一个的id
function getOneItem()
{
var allSel="";
if(document.form1.id.value) return document.form1.id.value;
for(i=0;i<document.form1.id.length;i++)
{
if(document.form1.id[i].checked)
{
allSel = document.form1.id[i].value;
break;
}
}
return allSel;
}
function selAll()
{
for(i=0;i<document.form1.id.length;i++)
{
if(!document.form1.id[i].checked)
{
document.form1.id[i].checked=true;
}
}
}
function noSelAll()
{
for(i=0;i<document.form1.id.length;i++)
{
if(document.form1.id[i].checked)
{
document.form1.id[i].checked=false;
}
}
}</script>
</head>
<body>
    <form id="form1" runat="server">
    <table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center"
        style="margin-top: 8px">
                <tr bgcolor="#E7E7E7">
            <td height="24" colspan="10" background="../../skin/images/wbg.gif">
                &nbsp;所有文章列表&nbsp;
            </td>
        </tr>
        <asp:Repeater ID="artList" runat="server" onitemcommand="artList_ItemCommand" >
            <HeaderTemplate>
                <tr align="center" bgcolor="#FAFAF1" height="22">
                    <td >选择
                    </td>
                    <td >ID
                    </td>
                    <td>
                        标题
                    </td>
                    <td >
                        类别
                    </td>
                    <td>
                        置顶
                    </td>
                    <td>
                        审核
                    </td>
                      <td >
                        简介
                    </td>
                      <td>
                        作者
                    </td>
                      <td>
                        时间
                    </td>
                      <td>
                        操作
                    </td>
                </tr>
              
            </HeaderTemplate>
            <ItemTemplate>
            <tr align='center' bgcolor="#FFFFFF" onmousemove="javascript:this.bgColor='#FCFDEE';"
            onmouseout="javascript:this.bgColor='#FFFFFF';" height="22">
            <td>
                <asp:CheckBox ID="checkbox1" runat="server" class="np"/>
            </td>
            <td>
       <%# DataBinder.Eval(Container.DataItem, "ID")%>   
            </td>
            <td align="left">
                 <%# DataBinder.Eval(Container.DataItem, "newtitle")%>
            </td>
            <td>
                 <%# ( DataBinder.Eval(Container.DataItem, "type"))%> 
            </td>
            <td>
            <%# setTop( DataBinder.Eval(Container.DataItem, "OrTop").ToString())%>
            </td>
            <td>
                <%# setCheck( DataBinder.Eval(Container.DataItem, "isHits").ToString())%> 
            </td>
            <td>
                <%# DataBinder.Eval(Container.DataItem, "ZaiYao")%> 
            </td>
            <td>
               <%# DataBinder.Eval(Container.DataItem, "Author")%> 
            </td>
            <td>
             <%# cutDate (DataBinder.Eval(Container.DataItem, "addTime").ToString())%>             </td>
            <td>
                <a href="Modfiy.aspx?id=<%# DataBinder.Eval(Container.DataItem, "ID")%>">编辑</a> | <a href=" ../../../<%# DataBinder.Eval(Container.DataItem, "ID")%> ">预览</a>
            </td>
        </tr>
            
            </ItemTemplate>
            <FooterTemplate>        <tr bgcolor="#FAFAF1">
            <td height="28" colspan="10">
                &nbsp; <a href="javascript:selAll()" class="coolbg">全选</a> <a href="javascript:noSelAll()"
                    class="coolbg">取消</a> <a href="javascript:updateArc()" class="coolbg">&nbsp;更新&nbsp;</a> <a href="javascript:delArc(0)" class="coolbg">&nbsp;删除&nbsp;</a>
            </td>
        </tr>
 
            </FooterTemplate>        </asp:Repeater>
                           <tr align="right" bgcolor="#EEF4EA">
            <td height="36" colspan="10" align="center">
              <asp:LinkButton ID="lbtnFirstPage" runat="server" onclick="lbtnFirstPage_Click" >页首</asp:LinkButton> 
<asp:LinkButton ID="lbtnpritPage" runat="server" onclick="lbtnpritPage_Click" >上一页</asp:LinkButton> 
<asp:LinkButton ID="lbtnNextPage" runat="server" onclick="lbtnNextPage_Click" >下一页</asp:LinkButton> 
<asp:LinkButton ID="lbtnDownPage" runat="server" onclick="lbtnDownPage_Click" >页尾</asp:LinkButton>&nbsp;&nbsp;&nbsp; 
第<asp:Label ID="labPage" runat="server" Text="Label"></asp:Label>页/共<asp:Label ID="LabCountPage" runat="server" Text="Label"></asp:Label>
                页              
                <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="删除" OnClientClick="return confirm('确认删除?')" />            </td>
        </tr>
    </table>
    </form>
</body>
</html>
我想在.ASPX.CS里面获取<%# DataBinder.Eval(Container.DataItem, "ID")%>   
ID的值,

解决方案 »

  1.   

    你用个label 把ID绑定在Lable的Text上
    //后台代码
    for (int a = 0; a < this.Repeater1.Items.Count; a++)
                {
                    Label labl = this.Repeater1.Items[0].FindControl("lable") as Label;
                    //这就得到了ID
                    string ID=labl.Text;
                }
      

  2.   

    你用个label 把ID绑定在Lable的Text上
    //后台代码
    for (int a = 0; a < this.Repeater1.Items.Count; a++)
       {
       Label labl = this.Repeater1.Items[0].FindControl("lable") as Label;
       //这就得到了ID
       string ID=labl.Text;
       }
      

  3.   

     foreach(RepeaterItem item in Repeater1.Items)
             {        
                 item.dataitem["ID"]
             }
      

  4.   

    前台:<ItemTemplate>
             <tr class="tdRow" id="<%#Eval("RecID") %>" onclick="GetID('<%#Eval("ID") %>');>
      外部放一个隐藏空间来取ID的值;
    js:
    GetRecID(id)
    {
    document.getElementById("隐藏控件id").value = id;
    }
    取值:
    int id=int。parse(隐藏控件id.value);
      

  5.   

    顶下,gridview的知道,repeater的不知道,呵呵
      

  6.   

    protected void Page_Load(object sender, EventArgs e)
        {
            int sum = 0;
            for (int i = 0; i < Repeater1.Rows.Count; i++)
            {           sum+=Convert.ToInt32(Repeater1.Rows[i].Cells[4].Text.ToString());
            }
            TextBox1.Text = sum.ToString();
        }
    可执行
    【拿不拿分不要紧,希望某些人不要昧着良心来骗分 
    骗分是小,误导所有关心这问题的人是大 
    我不是为了分而来,但最后很多人愿意把分给我!
    谢谢各位,让我成为上升最快达人!】 
      

  7.   

      不行啊。我就是想,通过获取。<%# DataBinder.Eval(Container.DataItem, "ID")%>   
    ID的值,来删除这条数据
      

  8.   

       是啊,二楼的那个不行,出现这个问题“未将对象引用设置到对象的实例”  还有Repeater1.Rows.Count; i++ 没有ROWS这个名称。
      

  9.   

    labl.Text;这是一个asp:label控件你难道没写
      

  10.   

    那个label必须放在你的控件里面绑定你的id