1
中獲取文本我有這樣的GridView:不能從一個TemplateField一個GridView
<asp:GridView runat="server" ID="gv_tList" OnRowDataBound="gv_tList_RowDataBound">
<Columns>
<asp:BoundField DataField="taskID" HeaderText="taskID" />
<asp:TemplateField HeaderText="Description" >
<ItemTemplate>
<asp:Label ID="descr" runat="server" Text='<%# Eval("Description") %>' ToolTip='<%# Eval("descr") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
和驗證碼:
protected void gv_tList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string taskID = e.Row.Cells[0].Text;
e.Row.Cells[1].Text = e.Row.Cells[1].Text.Length > 40 ? e.Row.Cells[1].Text.Substring(0, 40) + ".." : e.Row.Cells[1].Text;
}
}
e.Row.Cells [0]。文本返回文本字符串,但e.Row.Cells [1] .Text返回「」。任何人都知道如何從單元格中獲取文本?
感謝你的東西,就像一個魅力。 – 2015-02-06 08:33:30
@PresidentCamacho歡迎您將其標記爲答案,如果認爲這有幫助... :) – 2015-02-06 08:34:20
是的,但我必須等15分鐘才能創建問題。 – 2015-02-06 08:36:41