Monday, November 15, 2010

Creating Table dynamically in codebehind C#

.CS Code:
DataTable table = new DataTable();
table.Columns.Add("Name", typeof(string));
table.Columns.Add("MemberType", typeof(string));
table.Rows.Add(membername, membertype);
table.Rows.Add(memberType);
DataSet myds = new DataSet();
myds.Tables.Add(table);
 test.DataSource = myds;
 test.DataBind();
.ASPX Code:
<table >
                    <tr><td>
                    <asp:GridView ID="test" AutoGenerateColumns="false" runat="server" ShowHeader="false" GridLines="None">
                    <Columns>
                  
                   asp:BoundField DataField="Name" />
                    <asp:BoundField DataField="MemberType" />
                    </Columns>
                   
                    </asp:GridView></td></tr></table>

1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Online Training from India. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
    JavaScript Online Training from India

    ReplyDelete