Click here to Skip to main content
15,887,485 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Paging in DataList Pin
Christian Graus20-Oct-09 0:37
protectorChristian Graus20-Oct-09 0:37 
GeneralRe: Paging in DataList Pin
Shalini_U20-Oct-09 2:24
Shalini_U20-Oct-09 2:24 
QuestionMenu in ASP.NET Pin
Nanda_MR19-Oct-09 23:43
Nanda_MR19-Oct-09 23:43 
AnswerRe: Menu in ASP.NET Pin
Christian Graus20-Oct-09 0:02
protectorChristian Graus20-Oct-09 0:02 
GeneralRe: Menu in ASP.NET Pin
Nanda_MR20-Oct-09 0:18
Nanda_MR20-Oct-09 0:18 
GeneralRe: Menu in ASP.NET Pin
Christian Graus20-Oct-09 0:38
protectorChristian Graus20-Oct-09 0:38 
GeneralRe: Menu in ASP.NET Pin
Nanda_MR20-Oct-09 1:29
Nanda_MR20-Oct-09 1:29 
QuestionHow to show GridView on Page load and populate it with data from textboxes Pin
Nopo19-Oct-09 22:52
Nopo19-Oct-09 22:52 
Hi all,
I'm developing an ASP.Net app with C#. I have a Gridview that I want to show right on page load. I'm then capturing data into the textboxes and need to save it on the gridview right after clicking ADD button.

I can't get my Gridview displayed on page load and when saving the data from the textboxes to the Gridview I get this error:
"Column ‘Full Names’ does not belong to table"

This is what I've got in my code

html Design:
<asp:gridview id="dgInfoProfile1" runat="server" autogeneratecolumns="False">
<columns>
<asp:templatefield headertext="Full Names">
<asp:templatefield headertext="Identifying Number">
<asp:templatefield headertext="Passport Number">



Page_Load:

protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Full Names"));
dt.Columns.Add(new DataColumn("Identifying Number"));
dt.Columns.Add(new DataColumn("Passport Number"));
this.dgInfoProfile.DataSource = dt;
dgInfoProfile.DataBind();

}

ADD button:
protected void brtAdd_Click(object sender, EventArgs e)
{
try
{
DataRow dr = dt.NewRow();
dr["Full Names"] = txtFirstName3.Text;
dr["Identifying Number"] = txtIdentityNo.Text;
dr["Passport Number"] = txtPassportNo.Text;
dt.Rows.Add(dr);

//Bind GridView Here with this Table
this.dgInfoProfile.DataSource = dt;
dgInfoProfile.DataBind();

}
catch (Exception ex)
{
Response.Write(ex.Message);
}

}

I'm not sure where I've missed it, your advice and help in this is highly appreciated.

Thanks.
Confused | :confused:
AnswerRe: How to show GridView on Page load and populate it with data from textboxes Pin
nagendrathecoder19-Oct-09 23:00
nagendrathecoder19-Oct-09 23:00 
GeneralRe: How to show GridView on Page load and populate it with data from textboxes Pin
Nopo19-Oct-09 23:27
Nopo19-Oct-09 23:27 
GeneralRe: How to show GridView on Page load and populate it with data from textboxes Pin
nagendrathecoder19-Oct-09 23:32
nagendrathecoder19-Oct-09 23:32 
GeneralRe: How to show GridView on Page load and populate it with data from textboxes Pin
Nopo20-Oct-09 0:16
Nopo20-Oct-09 0:16 
GeneralRe: How to show GridView on Page load and populate it with data from textboxes Pin
nagendrathecoder20-Oct-09 0:18
nagendrathecoder20-Oct-09 0:18 
GeneralRe: How to show GridView on Page load and populate it with data from textboxes Pin
Nopo20-Oct-09 3:36
Nopo20-Oct-09 3:36 
GeneralRe: How to show GridView on Page load and populate it with data from textboxes Pin
Abhijit Jana20-Oct-09 4:09
professionalAbhijit Jana20-Oct-09 4:09 
GeneralRe: How to show GridView on Page load and populate it with data from textboxes Pin
nagendrathecoder20-Oct-09 18:34
nagendrathecoder20-Oct-09 18:34 
GeneralRe: How to show GridView on Page load and populate it with data from textboxes Pin
Leezo8729-Oct-09 3:19
Leezo8729-Oct-09 3:19 
GeneralRe: How to show GridView on Page load and populate it with data from textboxes Pin
TMFoust22-Dec-09 9:01
TMFoust22-Dec-09 9:01 
QuestionASP.NET Control: The Code Project Newsletter topics Control Pin
Gebbetje19-Oct-09 22:12
Gebbetje19-Oct-09 22:12 
AnswerRe: ASP.NET Control: The Code Project Newsletter topics Control Pin
Abhijit Jana19-Oct-09 22:48
professionalAbhijit Jana19-Oct-09 22:48 
QuestionRe: ASP.NET Control: The Code Project Newsletter topics Control Pin
Gebbetje20-Oct-09 0:21
Gebbetje20-Oct-09 0:21 
AnswerRe: ASP.NET Control: The Code Project Newsletter topics Control Pin
Abhijit Jana20-Oct-09 1:16
professionalAbhijit Jana20-Oct-09 1:16 
QuestionHow to get the treeview node count using javascript? Pin
meeram39519-Oct-09 22:07
meeram39519-Oct-09 22:07 
AnswerRe: How to get the treeview node count using javascript? Pin
Abhishek Sur19-Oct-09 22:40
professionalAbhishek Sur19-Oct-09 22:40 
AnswerRe: How to get the treeview node count using javascript? Pin
Nigel Ferrissey19-Oct-09 22:55
Nigel Ferrissey19-Oct-09 22:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.