我想在C#类库中创建这样的GridView:
这是用于界面的ASPXsource:
<asp:gridview ID="Gridview1" runat="server" ShowFooter="true" AutoGenerateColumns="false" onrowcreated="Gridview1_RowCreated">
<Columns>
<asp:BoundField DataField="RowNumber" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Header 1">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Header 2">
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Header 3">
<ItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</ItemTemplate>
<FooterStyle HorizontalAlign="Right" />
<FooterTemplate>
<asp:Button ID="ButtonAdd" runat="server" Text="Add New Row"
onclick="ButtonAdd_Click" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Remove</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
我想将ASPX格式化为CS(源代码),如下格式:
{
myGrid = new SPGridView();
myGrid.ShowFooter = true;
myGrid.AutoGenerateColumns = false;
myGrid.ID = "Gridview1";
SPBoundField dest = new SPBoundField();
dest.DataField = "Number";
dest.HeaderText = "Number";
TemplateField headerOne = new TemplateField();
base.CreateChildControls();
}
我不知道该怎么做,请帮忙。