Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
AnswerRe: architecture MVC Pin
Richard MacCutchan2-Mar-12 2:22
mveRichard MacCutchan2-Mar-12 2:22 
GeneralRe: architecture MVC Pin
MemberDotNetting2-Mar-12 2:36
MemberDotNetting2-Mar-12 2:36 
AnswerRe: architecture MVC Pin
Not Active2-Mar-12 2:25
mentorNot Active2-Mar-12 2:25 
GeneralRe: architecture MVC Pin
Pete O'Hanlon2-Mar-12 4:01
mvePete O'Hanlon2-Mar-12 4:01 
GeneralRe: architecture MVC Pin
Not Active2-Mar-12 5:51
mentorNot Active2-Mar-12 5:51 
AnswerRe: architecture MVC Pin
Pete O'Hanlon2-Mar-12 3:24
mvePete O'Hanlon2-Mar-12 3:24 
GeneralRe: architecture MVC Pin
MemberDotNetting2-Mar-12 3:41
MemberDotNetting2-Mar-12 3:41 
QuestionDataTable and DataSet? Pin
murali_utr1-Mar-12 17:32
murali_utr1-Mar-12 17:32 
$Exception {"Column 'Lab_SNo' does not belong to table LabBill."} System.Exception {System.ArgumentException}

What’s wrong in this code? While clicking the button the above exception is raised. Any help me to this problem.

C#
public partial class Lab_frmLabBilling : System.Web.UI.Page
{
    DataSet dsBill = new DataSet();
    DataTable dtBill = new DataTable("LabBill");
    
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {            

                InitializeDS();                 
            }          
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "HMS", ex.Message, false);
        }
    }

private void InitializeDS()
    {
        try
        {
            DataColumn dCol1 = new DataColumn("Lab_SNo",typeof(int));
            DataColumn dCol2 = new DataColumn("pk_lab_bill_id",typeof(int));
            DataColumn dCol3 = new DataColumn("GroupId",typeof(int));
            DataColumn dCol4 = new DataColumn("TestId",typeof(int));
            DataColumn dCol5 = new DataColumn("Lab_Test", typeof(string));
            DataColumn dCol6 = new DataColumn("Lab_Test_Cost", typeof(float));

            dtBill.Columns.Add(dCol1);
            dtBill.Columns.Add(dCol2);
            dtBill.Columns.Add(dCol3);
            dtBill.Columns.Add(dCol4);
            dtBill.Columns.Add(dCol5);
            dtBill.Columns.Add(dCol6);
            
            dsBill.Tables.Add(dtBill);

        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "HMS", ex.Message, false);
        }
    }

protected void btnGInsert_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtGroupName.Text == string.Empty)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "HMS", "Please Enter Group Name", false);
                return;
            }

            int iCount;

            iCount = dtBill.Columns.Count;
            iCount = dtBill.Rows.Count;            

            iCount++;

            DataRow drBill;

           
            drBill = dtBill.NewRow();
            drBill["Lab_SNo"] = iCount;
            drBill["pk_lab_bill_id"] = iCount;
            drBill["GroupId"] = int.Parse(Session["LabGroupId"].ToString());
            drBill["TestId"] = 0;
            drBill["Lab_Test"] = txtGroupName.Text;
            drBill["Lab_Test_Cost"] = float.Parse(Session["TestCost"].ToString());
            dtBill.Rows.Add(drBill);

            dsBill.AcceptChanges();

            grdLabBill.DataSource = dsBill;
            grdLabBill.DataBind();

            txtGroupName.Text = "";
            Session["GroupId"] = 0;
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "HMS", ex.Message, false);
        }
    }
}

Thanks in Advance!
Murali.M
Have A Nice Day!
Murali.M

Blog


modified 2-Mar-12 3:14am.

SuggestionRe: DataTable and DataSet? Pin
V.1-Mar-12 20:33
professionalV.1-Mar-12 20:33 
AnswerRe: DataTable and DataSet? Pin
V.1-Mar-12 20:41
professionalV.1-Mar-12 20:41 
AnswerRe: DataTable and DataSet? Pin
satalaj2-Mar-12 5:18
satalaj2-Mar-12 5:18 
AnswerRe: DataTable and DataSet? Pin
Rahul Rajat Singh3-Mar-12 0:43
professionalRahul Rajat Singh3-Mar-12 0:43 
QuestionHow to know application exit in Console started by Process.Start("cmd.exe")) Pin
gshen1-Mar-12 12:28
gshen1-Mar-12 12:28 
AnswerRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
Dave Kreskowiak1-Mar-12 13:03
mveDave Kreskowiak1-Mar-12 13:03 
GeneralRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
gshen1-Mar-12 13:08
gshen1-Mar-12 13:08 
GeneralRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
Dave Kreskowiak1-Mar-12 13:43
mveDave Kreskowiak1-Mar-12 13:43 
AnswerRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
PIEBALDconsult1-Mar-12 13:24
mvePIEBALDconsult1-Mar-12 13:24 
GeneralRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
gshen2-Mar-12 6:01
gshen2-Mar-12 6:01 
AnswerRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
Peter_in_27801-Mar-12 13:43
professionalPeter_in_27801-Mar-12 13:43 
GeneralRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
gshen2-Mar-12 6:07
gshen2-Mar-12 6:07 
AnswerRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
Bernhard Hiller1-Mar-12 20:38
Bernhard Hiller1-Mar-12 20:38 
GeneralRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
gshen2-Mar-12 6:09
gshen2-Mar-12 6:09 
AnswerRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
BobJanova1-Mar-12 23:28
BobJanova1-Mar-12 23:28 
GeneralRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
gshen2-Mar-12 6:11
gshen2-Mar-12 6:11 
AnswerRe: How to know application exit in Console started by Process.Start("cmd.exe")) Pin
#realJSOP2-Mar-12 4:21
mve#realJSOP2-Mar-12 4:21 

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.