|
| Creating Datasets on the Fly |
 |
Thu, 3 Apr 2008 14:31:14 +0000 |
I need c# code example that will be work for create dataset on the fly
Thanks
|
| Post Reply
|
| Re: Creating Datasets on the Fly |
 |
Thu, 3 Apr 2008 14:42:52 +0000 |
can u please be more specific?? creating datasets on fly... ???
|
| Post Reply
|
| Re: Creating Datasets on the Fly |
 |
Thu, 3 Apr 2008 14:59:04 +0000 |
Hi,
Use this code:
DataSet ds = new DataSet();
DataTable dt = new DataTable("Customers");
DataColumn col = dt.Columns.Add("CustID", typeof(Int32));
col.AllowDBNull = false;
col.Unique = true;
dt.Columns.Add("CustName", typeof(String));
dt.Columns.Add("CustStreet1", typeof(String));
dt.Columns.Add("CustStreet2", typeof(String));
ds.Tables.Add(dt);
HTH,
Suprotim Agarwal
|
| Post Reply
|
| Re: Creating Datasets on the Fly |
 |
Thu, 3 Apr 2008 15:23:31 +0000 |
Thanks for replay.
I don't understand why when I run the page nothing on it. It's empty
How I can add data in these cells? I need to work with a virtual data.
Now code on page
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="true" Width="77%">
</asp:GridView>
behinde:
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable("Customers");
DataColumn col = dt.Columns.Add("CustID", typeof(Int32));
col.AllowDBNull = false;
col.Unique = true;
dt.Columns.Add("CustName", typeof(String));
dt.Columns.Add("CustStreet1", typeof(String));
dt.Columns.Add("CustStreet2", typeof(String));
ds.Tables.Add(dt);
GridView1.DataSource = ds;
GridView1.DataBind();
}
|
| Post Reply
|
| Re: Creating Datasets on the Fly |
 |
Thu, 3 Apr 2008 17:11:00 +0000 |
Thanks for help :)
|
| Post Reply
|
|
|
|
|
|
|
|
|
|