Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无论如何,我在中继器datarow内设置了类,按数据ID查找,何时回发?_C#_Asp.net - Fatal编程技术网

C# 无论如何,我在中继器datarow内设置了类,按数据ID查找,何时回发?

C# 无论如何,我在中继器datarow内设置了类,按数据ID查找,何时回发?,c#,asp.net,C#,Asp.net,我想为中继器设置类,当doPostBack为我想要的那些数据ID设置类时,但dun noe可以/不能? 下面的代码只是示例,显示: <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" EnablePageMethods="true" />

我想为中继器设置类,当doPostBack为我想要的那些数据ID设置类时,但dun noe可以/不能? 下面的代码只是示例,显示:

<body>
  <form id="form1" runat="server">
      <asp:ScriptManager ID="ScriptManager1"  EnablePartialRendering="true"  runat="server" EnablePageMethods="true" />
     <asp:UpdatePanel ID="UpdatePanel2" runat="server" >
                <ContentTemplate>
                      <asp:Repeater ID="Repeater1" runat="server" DataSourceID="dsInbox">
                        <ItemTemplate>
                          <tr id="trInbox"> 
                            <td width="370px" height="25px"><div align="left" class="style95">&nbsp;<%# DisplaySubject(Eval("inbSubject").ToString(), Eval("inbMsg").ToString())%></div></td> 
                            <td width="80px" height="25px"><div align="left" class="style95">&nbsp;<%# Eval("inbCreatedAt","{0:MM-dd-yyyy}") %></div></td> 
                            <td width="94px" height="25px"><div align="left" class="style95">&nbsp;<%# Eval("DataId") %></div></td> 
                          </tr>   
                        </ItemTemplate>
                        </asp:Repeater>
                        </ContentTemplate>

            </asp:UpdatePanel>   

如果要为每行绑定设置一个类,并且需要数据ID,那么最好的方法是在每行绑定时处理它:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="dsInbox"
              OnItemDataBound="Repeater1_ItemDataBound">
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="dsInbox"
              OnItemDataBound="Repeater1_ItemDataBound">
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
    {
        MyType myItem = (MyType)e.Item.DataItem;
        var dataId = myItem.DataId;
        // Do whatever you need here.
    }
}