开发者

Reverse GridView into underlying data

I have a gridview with a boundfield and a templatefield (textbox). I'd like to iterate through the rows of the grid and get the underlying data out, including the data key for the grid rows themselves.

Given the following gridview row elements, how would I go about reverse engineering the data?

<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>


Something like this?

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜