<asp:DataList ID="jihuilist" runat="server" style="width:100%;" CellPadding="4" DataKeyField="id"
                      ForeColor="#333333">
                      <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                      <ItemTemplate>
                          <table border="0" cellspacing="0" cellpadding="0" style="width:100%; height:18px;">
                              <tr style="height:18px;">
                                <td style="width:5%; text-align:center;"><%# Eval("id").ToString() %></td>
                                <td style="width:18%; text-align:center;"><%# Eval("names").ToString() %></td>
                                <td style="width:12%; text-align:center;"><%# Eval("linkname").ToString() %></td>
                                <td style="width:12%; text-align:center;"><%# Eval("username").ToString() %></td>
                                <td style="width:10%; text-align:center;"><%# Eval("fzname").ToString() %></td>
                                <td style="width:8%; text-align:center;"><%# Eval("money").ToString() %></td>
                                <td style="width:13%; text-align:center;"><%# Eval("qiandantime").ToString() %></td>
                                <td style="width:8%; text-align:center;"><%# Eval("jilv").ToString() %></td>
                                <td style="width:7%; text-align:center;"><%# Eval("states").ToString() %></td>
                                <td style="width:7%; text-align:center;"><asp:Button ID="opener" runat="server" CommandName="select" Text="查看" /></td>
                              </tr>
                          </table>
                      </ItemTemplate>
                      <AlternatingItemStyle BackColor="White" />
                      <ItemStyle BackColor="#EFF3FB" />
                      <SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                      <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                  </asp:DataList>当我点击opener这个按钮的时候后台就能获取我点击行的id这一列的值?怎么做呢?用linkbutton又怎么做呢?

解决方案 »

  1.   

    请参考 
    http://www.ie512.com/news.aspx?id=205&no=1打开可能有点慢,有几个例子。
      

  2.   

    参考:
    http://www.cnblogs.com/insus/articles/2044053.html相关:
    http://www.cnblogs.com/insus/articles/2036884.html
    http://www.cnblogs.com/insus/archive/2011/06/30/2094151.html
      

  3.   

    <a href='Show.aspx?id=<%# Eval("Id")%>' ><%# Eval("Name")%></a>
    show.aspx
    string id=Request.QieryString["id"].ToString();
    控件查找使用
    foreach(DataListItem in DataList1.Items)
    {
    Label lbl= item.FindControl( "Label3") as Label ;
     } 
      

  4.   

    那就注册JS单击事件
    e.Row.Attributes.Add("onclick", "document.getElementById('TextBox5').value=" + e.Row.RowIndex + "");这有个gridview的原理差不多<asp:GridView ID="GridView5" runat="server" AutoGenerateColumns="False" onrowdatabound="GridView5_RowDataBound" >
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <%#DataBinder.Eval(Container,"DataItem.ID") %>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            </asp:GridView>
            <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>protected void GridView5_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("style", "cursor:pointer");
                e.Row.Attributes.Add("onclick", "document.getElementById('TextBox5').value=" + e.Row.RowIndex + "");
            }
        }同事期待别人给你写好的DEMO
      

  5.   

    为什么不使用GridView呢?把列全都设置为HyperLinkComun,设置样式为普通的文本一样的样式就行了。
      

  6.   

    我是想点击那个linkbutton之后获取到被点击那行的ID然后根据ID来修改资料
      

  7.   

    你已经设好DataKeyField是吧!然后把那个CommandName="select"  改为 CommandName="update"
    这就触发jihuilist_UpdateCommand
        protected void jihuilist_UpdateCommand(object source, DataListCommandEventArgs e)
        {
           string Id=  this.jihuilist.DataKeys[e.Item.ItemIndex].ToString();
           Response.Write(Id);
        }
    可以获得ID了
      

  8.   

    http://zonghe.17xie.com/book/10317108/391706279.html