繁体   English   中英

如何在HTML中创建链接,与在ASP.NET中的中继器中创建链接按钮相同

[英]How to create links in html same as Linkbutton as in a Repeater in ASP.NET

我有一个项目,列出了数据库中的许多问题。这些问题会问人们并从中获得票数。 当我选择任何问题时,它需要在图表上显示他们的投票及其投票。我不想使用重复器。如何从列表中获得问题的ID。在重复器中,我使用commandArgument,但是在我的策略中,这是不允许的使用系统。我需要使用任何链接通过命令参数调用某些内容,例如在转发器功能中使用链接按钮。我该怎么做。 请帮我。

如果我使用中继器,我可以得到如下问题的ID:

int ID = General.StrtoInt(e.CommandArgument.ToString());

当我使用中继器时,我会这样使用:

<table>
    <tbody>
        <asp:Repeater runat="server" ID="RptRecord" OnItemDataBound="RptRecord_ItemDataBound" OnItemCommand="RptRecord_ItemCommand">
            <ItemTemplate>
                <tr class="odd gradeX">
                    <td class="hidden-phone" style="text-align: center">
                        <asp:Literal ID="LblSiraNo" runat="server" />
                    </td>
                    <td class="hidden-phone" style="text-align: center">
                        <asp:Literal ID="LblSoru" runat="server" />
                    </td>
                    <td class="hidden-phone" style="text-align: center">
                        <asp:CheckBox ID="ChckIsVisible" runat="server" Enabled="false" />
                    </td>
                    <td class="hidden-phone" style="text-align: center">
                        <asp:LinkButton ID="LnkBtnIstatistik" runat="server" class="btn blue mini" CommandName="CmdName_Istatistik"></asp:LinkButton>&nbsp;&nbsp;
                        <asp:LinkButton ID="LnkBtnGuncelle" runat="server" class="btn green mini" CommandName="CmdName_Guncelle" Visible="false" OnClientClick="showPopup()"></asp:LinkButton>&nbsp;&nbsp;
                        <asp:LinkButton ID="LnkBtnSil" runat="server" class="btn red mini" CommandName="CmdName_Sil" Visible="false" OnClientClick="if(uyar()) showPopup();"></asp:LinkButton>
                    </td>
                </tr>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <tr class="odd gradeX" style="background-color: bisque">
                    <td class="hidden-phone" style="text-align: center">
                        <asp:Literal ID="LblSiraNo" runat="server" />
                    </td>
                    <td class="hidden-phone" style="text-align: center">
                        <asp:Literal ID="LblSoru" runat="server" />
                    </td>
                    <td class="hidden-phone" style="text-align: center">
                        <asp:CheckBox ID="ChckIsVisible" runat="server" Enabled="false" />
                    </td>
                    <td class="hidden-phone" style="text-align: center">
                        <asp:LinkButton ID="LnkBtnIstatistik" runat="server" class="btn blue mini" CommandName="CmdName_Istatistik"></asp:LinkButton>&nbsp;&nbsp;
                        <asp:LinkButton ID="LnkBtnGuncelle" runat="server" class="btn green mini" CommandName="CmdName_Guncelle" Visible="false" OnClientClick="showPopup()"></asp:LinkButton>&nbsp;&nbsp;
                        <asp:LinkButton ID="LnkBtnSil" runat="server" class="btn red mini" CommandName="CmdName_Sil" Visible="false" OnClientClick="if(uyar()) showPopup();"></asp:LinkButton>
                    </td>
                </tr>
            </AlternatingItemTemplate>
        </asp:Repeater>
    </tbody>
</table>

这是使用html的asp.net代码:

string a1 = "", a2 = "", a3 = "", a4 = "", a5 = "";
   foreach (var item in lst_cevap1)
    {
       BirimVO brm = birimBUS.Birim(item.PoliklinikID);


       str += "     <div class=\"portlet-body\">";
      // bu kısım tablonun body kısmının head kısmı


  str += "<table class=\"table table-striped table-bordered table-advance table-hover\">               ";
  str += "<thead>                                                                                ";
  str += "  <tr>                                                                               ";
  str += "  <th>" + GetContent.Cevir((int)eCeviri.Sıra_No) + "</th>                                   ";
  str += "  <th> "+birimAdi + "</th>                                   ";
  str += "  <th>" + Cevap1 + "</th>    ";
  str += "  <th>" + Cevap2 + "</th>    ";
  str += "  <th>" + Cevap3 + "</th>    ";
  str += "  <th>" + Cevap4 + "</th>    ";
  str += "  <th>" + Cevap5 + "</th>    ";
  str += "  <th>" + GetContent.Cevir((int)eCeviri.Toplam) + "</th>                                   ";
  str += " <th> Chart Göster                                </th>                                   ";
  str += "                  </tr>                                                                              ";
   str += "             </thead>                                                                               ";
   str += "             <tbody>                                                                                ";

   sira++;
   str += "                 <tr>                                                                               ";
   str += "                     <td>" + sira.ToString() + "</td>                                             ";
   str += "                     <td>";


    str += questionV1.Text;
                                    if (Cevap3 !="")
                                    {
                                        a3 = item.iyisayisi.ToString();
                                    }
                                    if (Cevap4 != "")
                                    {
                                        a4 = item.ortasayisi.ToString();
                                    }
                                    if (Cevap5 != "")
                                    {
                                        a5 = item.kotusayisi.ToString();
                                    }
                                    str += "</td>                  ";
                                    str += "                        <td>" + item.cevap1sayisi + "</td>                                             ";
                                    str += "                        <td>" + item.cevap1sayisi + "</td>                                             ";
                                    str += "                        <td>" + a3 + "</td>                                             ";
                                    str += "                        <td>" + a4 + "</td>                         ";
                                    str += "                        <td>" + a5+ "</td>    ";
                                    str += "                        <td>" + item.toplam + "</td>                    ";
                                    str += "                        <td>"+BirimID+","+questionV1.ID+"</td>                           ";
                                    str += "                    </tr>                                                                              ";
                                }
                                #endregion

从数据库加载您的问题。 遍历问题,并手动创建所需的控件,手动分配唯一ID,并结合名称和数据库ID,例如lblQuestion101

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM