-1
我打算創建一個4列10行的gridview板。我想使用循環。我不知道如何處理CS代碼。我是一名初學者,我正在練習作爲一個例子。請幫助。創建一個ASP.net GridView板(沒有服務器連接)
的.aspx
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true"
AllowSorting="True"
AllowPaging="True" PageSize="10" onrowdatabound="GridView1_RowDataBound"
ondatabound="GridView1_DataBound" EmptyDataText="NO">
<EmptyDataTemplate>No Data</EmptyDataTemplate>
</asp:GridView>
.aspx.cs
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
{
e.Row.Cells[0].Text = "Complete";
}
}
protected void GridView1_DataBound(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
var str = GridView1.DataKeys[row.RowIndex]["SomeColumnName"];
}
如果你是一個初學者,我建議你瞭解MVC,而不是Web表單 –
我添加了一個簡單的例子 – AsifAli72090