Click here to Skip to main content
15,936,119 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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" />


                        <asp:TemplateField HeaderText="Degree Level">
                                <asp:DropDownList ID="degree" runat="server" AutoPostBack="True">
                                    <asp:ListItem>Post Graduation</asp:ListItem>
                        <asp:TemplateField HeaderText="Degree Name">
                                <asp:TextBox Id="degree" runat ="server"></asp:TextBox>
                        <asp:TemplateField HeaderText="Passing Year">
                                <asp:TextBox ID="passingyear" runat="server" MaxLength ="4"></asp:TextBox>
                        <asp:TemplateField HeaderText="Percentage">
                                <asp:TextBox ID="percentage" runat="server" MaxLength ="2"></asp:TextBox>
thatraja 26-Feb-11 13:50pm    
Include your code of code-behind here too.

GridView is not rendered until you set its dataSource property and call dataBind().

Try following
protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            int[] i = new int[10];
            GridView1.DataSource = i;


You may change the Length of the Array to get more rows.

int[] i = new int[100];

Change the Control name in your GridView
        <asp:TextBox Id="dregreName"     runat="server"></asp:TextBox>
Share this answer
you can not see this grid if you did not provide datasource to the grid because grid is used to show some bound data
i used following line at page load to show 3 lines in grid
GridView1.DataSource = new string[] { "", "", "" };

Hope u could use this.

Share this answer
I think the following links will help you out:

how to use GridView in
DataBinding to GridView
GridView Control Detail

If i misunderstand your question, please feel free to correct me.I hope the above information will be helpful. If you have more concerns, please let me know.

If this would be really helpful to you then don't forgot to Vote and Make Answer as Accepted.
Share this answer
solution not working ... Please post if you have any other solution to this problem ...
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900