473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Manually adding rows to Gridview in asp.net 2.0..

Here is my code.while i am trying to run this code.Error is raising.Can any one help me in this?

Column 'Trans Seq No' does not belong to table .


protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
AddingItemstoGridView();
}

}
private void AddingItemstoGridView()
{
DataTable dt = new DataTable("tblTest");
DataColumn dc1 = new DataColumn();
dc1.DataType = typeof(String);
dc1.ColumnName = "Trans Seq No";
DataColumn dc2 = new DataColumn();
dc2.DataType = typeof(String);
dc2.ColumnName = "Trans Ref No";
DataColumn dc3 = new DataColumn();
dc3.DataType = typeof(String);
dc3.ColumnName = "SE No";
DataColumn dc4 = new DataColumn();
dc4.DataType = typeof(String);
dc4.ColumnName = "Trans Date";
DataColumn dc5= new DataColumn();
dc5.DataType = typeof(String);
dc5.ColumnName = "Trans Post Date";
DataColumn dc6 = new DataColumn();
dc6.DataType = typeof(String);
dc6.ColumnName = "Trans Amount";
DataColumn dc7= new DataColumn();
dc7.DataType = typeof(String);
dc7.ColumnName = "Status";

dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
dt.Columns.Add(dc5);
dt.Columns.Add(dc6);
dt.Columns.Add(dc7);

//DataRow dr = dt.NewRow();

Session["Trans Seq No"] += "01" + "|";
Session["Trans Ref No"] += "111111111111111" + "|";
Session["SE No"] += "1234567890" + "|";
Session["Trans Date"] += "12/09/07" + "|";
Session["Trans Post Date"] += "12/09/07" + "|";
Session["Trans Amount"] += "100.00" + "|";
Session["Status"] += "Reject" + "|";
CreateTable();
}
public void CreateTable()
{
string[] sa = Session["Trans Seq No"].ToString().Split('|');
string[] sb = Session["Trans Ref No"].ToString().Split('|');
string[] sc = Session["SE No"].ToString().Split('|');
string[] sd = Session["Trans Date"].ToString().Split('|');
string[] se = Session["Trans Post Date"].ToString().Split('|');
string[] sf = Session["Trans Amount"].ToString().Split('|');
string[] sg = Session["Status"].ToString().Split('|');
int recordnum = sa.Length;
dt = new DataTable();
for (int j = 0; j < recordnum - 1; j++)
{
DataRow dr = dt.NewRow();
dr["Trans Seq No"] = sa[j].ToString(); /*here is the error
dr["Trans Ref No"] = sb[j].ToString();
dr["SE No"] = sc[j].ToString();
dr["Trans Date"] = sd[j].ToString();
dr["Trans Post Date"] = se[j].ToString();
dr["Trans Amount"] = sf[j].ToString();
dr["Status"] = sg[j].ToString();
dt.Rows.Add(dr);
}
gvTransactionalDetails .DataSource = dt.DefaultView;
gvTransactionalDetails.DataBind();
}

thanking u
Oct 26 '07 #1
1 2461
kenobewan
4,871 Expert 4TB
Which line is giving you the error?
Oct 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Loading name... | last post by:
hey asp.net 2.0 Is it possible to add records to a database via a GridView, I mean in the GridView the user add new rows which are saved back to the database? I know I can edit rows, but...
1
by: VMI | last post by:
In my web application, I have a gridview that, on load, is populated from a table. During the application, I can add rows to the gridview. How can I add these rows to the actual DB table? How do I...
1
by: JB | last post by:
I'm dynamically creating a Gridview object and filling it with contents from an ArrayList as follows: GridView2.AutoGenerateColumns = true; GridView2.DataSource = ArrayListObject;...
2
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent...
0
by: ganesh22 | last post by:
Hi... Iam using GridView in asp.net(2.0) .My requirement is user can add,update,delete in gridview I written the code for add & update but can u help adding rows in grid view My code: ...
1
by: bJames | last post by:
Hi I've been all around looking for an answer to this question, but can't find it. I've got a gridview with a single unbound column. It's got a textbox and button in the footer row. I"m trying to...
1
by: COHENMARVIN | last post by:
I have a gridview and I need to know the number of rows in it. I find the Page_load and the Gridview_Load events are too early to find out the number of rows. I can use the Gridview_databound...
2
by: shrikanthn | last post by:
Hi All, i am adding some data into GridView (adding 4 to 5 rows) at runtime in asp.net page using c#. but getting outofbond error.
7
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I'm adding subheadings to a gridview. Each sub head has a few link buttons. I'm adding the controls in the rowdatabound event code follows: sorry about the length here. I have to be missing...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.