首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从表的html列中获取数据并传递给C#

如何从表的html列中获取数据并传递给C#
EN

Stack Overflow用户
提问于 2020-12-29 09:49:05
回答 1查看 60关注 0票数 0

我有一个html表,其中包含来自sql的数据。每一行都有一个“给予”按钮。我需要当按下时,“代码”单元格的值被转移到C#代码中。"code“列具有唯一的值,可以用作id。

代码语言:javascript
运行
复制
<asp:Repeater ID="Repeater1" runat="server">  
    <HeaderTemplate>
<table class="table table-striped table-hover">
  <thead class="thead-light">
    <tr>
      <th></th>
      <th scope="col">name</th>
      <th scope="col">sur</th>
      <th scope="col">code</th>
    </tr>
  </thead>
    </HeaderTemplate>
     <ItemTemplate>
  <tbody id="myTable">
    <tr>
      <th><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">give</button> </th>
     
        <td><%# Eval("name")%></td>
        <td><%# Eval("sur")%></td>
        <td><%# Eval("code")%></td>
              
    </tr>
      </tbody>
   </itemtemplate>
     <FooterTemplate>
         
   </table>

        </FooterTemplate>
    
     </asp:Repeater>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-29 10:53:15

如果我真的明白你的问题,

您可以使用commandArgument,但是首先,如果您没有任何guid或Id,您可以在sql或frontSide中创建它,那么我认为sql查询中的newID()是完美的,然后将其放在隐藏值或frontSide中的CommandArgument中。然后C#端您可以处理Repeater1_ItemCommand中的所有进程并从

代码语言:javascript
运行
复制
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    if (e.CommandName == "guid")
    {
        Int32 id = Convert.ToInt32(e.CommandArgument);
    }
}

还请看Pass an ID to OnClick event with Repeater control?一篇文章

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65490264

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档