How I can create dynamic GridView with dynamic number of row When click on button
and put in one column DropDownList .
GridView is a databound control. It means that it shows what is in the datasource. To add a row, you need to add an item to the datasource and re-bind the gridview. You can't add rows to the gridview directly.
Your question is pretty brief, but if if i think i understand what you want to do, you could try this:
in the codebehind of your button
List<string> ThisIsYourList = new List<string>();
Gridview1.DataSource = ThisIsYourList;
Gridview1.DataBind();
if you want to add a dropdownlist to every row, you need to add an itemtemplate to your gridview like this:
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"/>
</ItemTemplate>
</asp:TemplateField>
You add this itemtemplate anywhere between the tags of your gridview.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.