本文介绍了在网格视图中看不到数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了我想使用gridview从用户那里接受数据的代码.现在,我无法在页面加载事件中看到gridview. ...
I write the code where I want to accept the data from user using gridview .. now m unable to see the the gridview on the page load event. ...
<asp:GridView ID="GridView1" runat="server" CellPadding="4"
EnableModelValidation="True" ForeColor="#333333" GridLines="Vertical"
AutoGenerateColumns="False" >
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle Font-Bold ="true" ForeColor ="#333333" BackColor="#D1DDF1" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Degree Level">
<ItemTemplate>
<asp:DropDownList ID="degree" runat="server" AutoPostBack="True">
<asp:ListItem>Select..</asp:ListItem>
<asp:ListItem>SSC</asp:ListItem>
<asp:ListItem>HSC</asp:ListItem>
<asp:ListItem>Diploma</asp:ListItem>
<asp:ListItem>Graduation</asp:ListItem>
<asp:ListItem>Post Graduation</asp:ListItem>
<asp:ListItem>PHD</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Degree Name">
<ItemTemplate>
<asp:TextBox Id="degree" runat ="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Passing Year">
<ItemTemplate>
<asp:TextBox ID="passingyear" runat="server" MaxLength ="4"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Percentage">
<ItemTemplate>
<asp:TextBox ID="percentage" runat="server" MaxLength ="2"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
推荐答案
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int[] i = new int[10];
GridView1.DataSource = i;
GridView1.DataBind();
}
}
您可以更改数组的长度以获取更多行.
You may change the Length of the Array to get more rows.
int[] i = new int[100];
在GridView中更改控件名称
Change the Control name in your GridView
<ItemTemplate>
<asp:TextBox Id="dregreName" runat="server"></asp:TextBox>
</ItemTemplate>
GridView1.DataSource = new string[] { "", "", "" };
希望你可以使用它.
--Pankaj
Hope u could use this.
--Pankaj
这篇关于在网格视图中看不到数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!