這是我的GridView標記。如何從GridView中的模板字段獲取值?
<Columns>
<asp:TemplateField HeaderText="Customer Name">
<ItemTemplate>
<asp:Label ID="lblname" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Customer.Name")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PickUpPoint">
<ItemTemplate>
<asp:Label ID="lblPickUpPoint" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Pickuppoint")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
我有一個按鈕,它將值存儲在excel對象的工作表單元格中。
for (int i = 0; i < GridView2.Rows.Count; i++)
{
for (int j = 0; j < GridView2.Rows[i].Cells.Count; j++)
{
xlWorkSheet.Cells[i + 1, j + 1] = GridView2.Rows[i].Cells[j].Text;
}
}
如何獲得GridView控件的值,並將其存儲在一個工作表中,作爲GridView2.Rows[i].Cells[j]
。文本返回空字符串。
好吧......但是,如何做到這一點對於其他控件...如果循環進入第二個tym ...我如何將標籤指向'lblPickUpPoint' .... 謝謝 – Kulkarni
作品就像一個魅力男人....謝謝...... 編輯:現在我正在獲取Gridview中的所有數據.. 我怎樣才能使'TemplateField HeaderText'進入工作表內部...... 在此先感謝... – Kulkarni
我如何使'TemplateField HeaderText'進入工作表內部以及......? – Kulkarni