【问题标题】:Reverse GridView into underlying data将 GridView 反转为底层数据
【发布时间】:2023-04-07 13:23:02
【问题描述】:

我有一个带有边界字段和模板字段(文本框)的网格视图。我想遍历网格的行并获取底层数据,包括网格行本身的数据键。

鉴于以下 gridview 行元素,我将如何对数据进行逆向工程?

<asp:BoundField HeaderText="Due Date" DataField="DueDate" 
       SortExpression="DueDate"
        DataFormatString="{0:M/dd/yyyy}"
       ></asp:BoundField>


     <asp:TemplateField HeaderText="Quota">
         <ItemTemplate>  
          <asp:TextBox ID="txtDraftQuota" runat="server" Width="25px" MaxLength="3" 
          Value='<%# Eval("Quota") %>' />
         </ItemTemplate>
     </asp:TemplateField>

【问题讨论】:

  • 您需要在客户端执行此操作吗?

标签: asp.net gridview datatable


【解决方案1】:

这样的?

foreach (GridViewRow row in GridView1.Rows)
{
  string dueDate = row.Cells[0].Text;
  string quota = ((TextBox)row.Cells[1].FindControl("txtDraftQuota")).Text;

  //Do something with these values
}

【讨论】:

    猜你喜欢
    • 2011-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-04
    • 1970-01-01
    • 2019-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多