0
我在C#中使用ASP.NET中的GridView。我在Runtime中將Templete字段列添加到GridView,列成功添加,行中需要的文本。但是填充的GridView進行任何按鈕,點擊來自行控制事件刪除,行後,我在Templete現場文字和TextBox控件作爲ItemTempete .....Asp.Net GridView在運行時添加模板字段
任何幫助......
我在C#中使用ASP.NET中的GridView。我在Runtime中將Templete字段列添加到GridView,列成功添加,行中需要的文本。但是填充的GridView進行任何按鈕,點擊來自行控制事件刪除,行後,我在Templete現場文字和TextBox控件作爲ItemTempete .....Asp.Net GridView在運行時添加模板字段
任何幫助......
<asp:GridView runat="server" ID="gridView">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton runat="server" ID="lnkTest"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
然後在你的rowdatabound事件中,你可以找到它並做你想做的任何事
void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Entity entity = e.Row.DataItem as Entity;
LinkButton lnkTest = e.Row.FindControl("lnkTest") as LinkButton;
lnkTest.CommandArgument = entity.ID.ToString();
lnkTest.Text = entity.Name;
}
}