This is scenario that many people stuck with so I did some investigation and finally came a good standard MSDN specified solution. So please take the advantage of it. Have nice cording ;)
Step 01
Add a gridview in to your aspx.(With no Columns)
<asp:GridView ID="GridView" runat="server" BorderWidth="0px" Width="100%" ShowHeader="False">
</asp:GridView>
Style it as you want.
Step 02
Code behind.Bind the data.
private void PopulateGridView()
{
GridView.DataSource = GetData();
GridView.DataBind();
}
private DataTable GetData()
{
DataTable table = new DataTable();
table.Columns.Add(GridColumnName, typeof(string));
table.Columns.Add(GridColumnEmail, typeof(string));
table.Rows.Add("Asaj saii", "asag@IBM.com");
GridFormatter gridformatter = new GridFormatter();
DataTable datatable = gridformatter.FormatDataTable();
gridformatter.AddDataRow(Localization.GetString("Name", this.LocalResourceFile), table.Rows[0][0].ToString(), datatable);
gridformatter.AddDataRow(Localization.GetString("Email", this.LocalResourceFile), table.Rows[0][1].ToString(), datatable);
return datatable;
}
public class GridFormatter
{
public DataTable FormatDataTable()
{
DataTable datatable = new DataTable();
datatable.Columns.Add("Description", System.Type.GetType("System.String"));
datatable.Columns.Add("Value", System.Type.GetType("System.String"));
return datatable;
}
public void AddDataRow(string description, string value, DataTable dt)
{
DataRow datarow;
datarow = dt.NewRow();
datarow["Description"] = description;
datarow["Value"] = value;
dt.Rows.Add(datarow);
}
}
Step 03
Test it.Cheers!