Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4074912
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:13:53+00:00 2026-05-20T17:13:53+00:00

Please have a look at my code below and tell me where i am

  • 0

Please have a look at my code below and tell me where i am going wrong.

case "particulars.aspx":
   dt = JobCardManager.GetParticularsByJobId(id);
   hidJobId.Value = id.ToString();
   if (dt != null && dt.Rows.Count > 0)
   {
      gvParticulars.DataSource = dt;
      gvParticulars.DataBind();
   }
   else
   {
      **dt.Rows.Add(dt.NewRow());**
      gvParticulars.DataSource = dt;
      gvParticulars.DataBind();

      int TotalColumns = gvParticulars.Rows[0].Cells.Count;
      gvParticulars.Rows[0].Cells.Clear();
      gvParticulars.Rows[0].Cells.Add(new TableCell());
      gvParticulars.Rows[0].Cells[0].ColumnSpan = TotalColumns;
      gvParticulars.Rows[0].Cells[0].Text = "No Record Found";
   }

   ddlJobs.Enabled = false;
   gvParticulars.ShowFooter = true;
   break;

What I want to achieve is that in case when the dt don’t have any rows, I need to display a new row in the footer, controls are already added in footer. My insert update and add new process all are carried out from grid itself.

So in case if my datatable comes null, then at the starred line, I am getting the error, “Column does not allow null”. Where in database all columns have Allow Null checkboxes are checked. Please help.

[Update]

I am not retriving primary key in the query. Only the editable parts of the table.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:13:54+00:00Added an answer on May 20, 2026 at 5:13 pm

    You might want to read the schema information when you fill the dataset. I’m not sure whether this would solve your problem, but I suspect it will. Without the schema, your datatable won’t know whether the column accepts null or not.

    da.FillSchema(ds, SchemaType.Source);
    da.Fill(ds);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please have a look at the code below: import string from collections import defaultdict
Please have a look on the code below .. <div id=click_me>Save</div> <div id=blocks_sortable> <div
Could you please have a look at my code below. #!C:\Perl\bin\perl.exe use strict; use
I have a query on this. Please look at the sample code below: UIButton
I have just started to look at .NET 3.5 so please forgive me if
I might have wandered into wrong direction so please help. I have a page
I have some thread-related questions, assuming the following code. Please ignore the possible inefficiency
I have below code in html <div id=divTest> Hello <input type=text id=txtID/> <input type=text
Please if you have used NHibernate and Entity Frameworks, please contrast your experiences.
Please help! Background info I have a WPF application which accesses a SQL Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.