如何使用文本框参数在gridiview中添加新的dinamically列 [英] how to add new dinamically column in gridiview using parameter of textbox
本文介绍了如何使用文本框参数在gridiview中添加新的dinamically列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的设计:
列名/标题ID =文本框1
列文本/标题文本=文本框2
列大小= textbox3
i有一个gridview,如何使用templatefield header =来自textbox1,templatefield的输入添加新列id =从textbox1输入,模板字段width =从文本框3输入。
这是我的代码aspx:
< asp:GridView ID = GridView1 runat = 服务器 AutoGenerateColumns = False
ShowFooter = True CellPadding = 4 ForeColor = #333333
< span class =code-attribute> 宽度 = 732px 高度 = 16px AllowSorting = True
PageSize = 20 AllowPaging = True >
< 列 >
< asp:TemplateField HeaderText = 报告ID < span class =code-attribute> 可见 = False >
< ItemTemplate >
< asp:标签 ID = lblreport_id 宽度 = 20px runat < span class =code-keyword> = server ForeColor = 黑色
文字 =' <% #Eval( report_id)%> ' > < / asp:Label >
< / ItemTemplate >
< FooterTemplate >
< asp:TextBox ID = txtreport_id 宽度 = 20px runat = server > < / asp:TextBox >
< / FooterTemplate >
< ControlStyle 宽度 = 20px / >
< HeaderStyle ForeColor = 白色 / >
< ItemStyle 宽度 = 20px / >
< / asp:TemplateField >
您的回答非常有用,谢谢:)
解决方案
< blockquote>阅读文章并实施。 动态地将BoundField和TemplateField列添加到ASP中的GridView .Net [ ^ ]
this is my design :
Column Name / Header Id = textbox1
Column Text / Header Text = textbox2
Column size = textbox3
i have a gridview, how to add new column using templatefield header = input from textbox1, templatefield id= input from textbox1, and template field width = input from textbox 3.
this is my code aspx :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
ShowFooter="True" CellPadding="4" ForeColor="#333333"
Width="732px" Height="16px" AllowSorting="True"
PageSize="20" AllowPaging="True">
<Columns>
<asp:TemplateField HeaderText="Report Id" Visible="False">
<ItemTemplate>
<asp:Label ID="lblreport_id" Width = "20px" runat="server" ForeColor="Black"
Text='<%# Eval("report_id") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtreport_id" Width = "20px" runat="server"></asp:TextBox>
</FooterTemplate>
<ControlStyle Width="20px" />
<HeaderStyle ForeColor="White" />
<ItemStyle Width="20px" />
</asp:TemplateField>
your answer is very helpful, thanks :)
解决方案
Read the article and implement. Dynamically add BoundField and TemplateField Columns to GridView in ASP.Net[^]
这篇关于如何使用文本框参数在gridiview中添加新的dinamically列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文