|
Ok, got it.
Almost there but still have a couple more questions.
1, I didn't get a response to the registerNumber and bregisterNumber fields in the LoadTable2 method.
They are giving errors that they don't exist.
Finally, another method is giving me errors.
The
private void SetPreviousData2(string registerNumber, string bregisterNumber)
When called below, is giving errors that SetPreviousData2 must have a return type.
SetPreviousData2(registerNumber, bregisterNumber);
Do I need to get rid of those as well?
If I do get rid of that method, then when I click NEXT to go to page2, it is blank.
modified 21-Sep-17 16:30pm.
|
|
|
|
|
1) Look at the code I posted[^]. The LoadTable2 method does not contain any mention of registerNumber or bregisterNumber .
You added that reference back in[^] within the if (dta.Rows.Count == 0) block, which is not required, and which I told you to remove[^].
Once again, the LoadTable2 method does not create any rows. Those rows are created in the PopulateRecord method.
2) You have never posted the definition of the SetPreviousData2 method. If you can't work out how to fix it, then you're going to need to post it, along with the full details of the error.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you very sir.
I truly appreciate your patience.
SetPreviousData2 takes two arguments, RegisterNumber( to populate MarineRegNo from Repeater1 to AregNo for Repeater2) and bregisterNumber which populates VesselRegNo from Repeater1 to coastGuardNumber for Repeater2) when user clicks the NEXT button.
When SetPreviousData2(registerNumber, bregisterNumber) is called, I get an error that method must have a return type.
I suspect that those two arguments may no longer be needed given the solution you have given me.
However, even after I remove them from SetPreviousData2(...) method and I remove them from where it is called, I still get that error.
Here is where it is called as well as the method and just to avoid me coming to ask more questions, I think and please confirm that if in fact, it is no longer needed, then any place else on the page where they are referenced, I will remove them?
SetPreviousData2(registerNumber, bregisterNumber);
private void SetPreviousData2(string registerNumber, string bregisterNumber)
{
int rowIndex = 0;
if (ViewState["CurrentTable"] != null)
{
DataTable dt = (DataTable)ViewState["CurrentTable"];
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
TextBox tbaircnty = (TextBox)Repeater2.Items[rowIndex].FindControl("aircraftcnty");
TextBox tbTextBox2 = (TextBox)Repeater2.Items[rowIndex].FindControl("aRegNo");
TextBox tbaMake = (TextBox)Repeater2.Items[rowIndex].FindControl("aMake");
TextBox tbmMake = (TextBox)Repeater2.Items[rowIndex].FindControl("mMake");
TextBox tbaModelNo = (TextBox)Repeater2.Items[rowIndex].FindControl("aModelNo");
TextBox tbmModelNo = (TextBox)Repeater2.Items[rowIndex].FindControl("mModelNo");
TextBox tbboatYrBuilt = (TextBox)Repeater2.Items[rowIndex].FindControl("boatYrBuilt");
TextBox tbmotorYrBuilt = (TextBox)Repeater2.Items[rowIndex].FindControl("motorYrBuilt");
TextBox tbblength = (TextBox)Repeater2.Items[rowIndex].FindControl("blength");
TextBox tbhullmaterial = (TextBox)Repeater2.Items[rowIndex].FindControl("hullmaterial");
TextBox tbmhorsepower = (TextBox)Repeater2.Items[rowIndex].FindControl("mhorsepower");
RadioButtonList rblhoreslist = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rdlmhorsepType");
TextBox tbdatePurchased = (TextBox)Repeater2.Items[rowIndex].FindControl("txtdatePurchased");
TextBox tbrbmdatePurchased = (TextBox)Repeater2.Items[rowIndex].FindControl("mdatePurchased");
RadioButtonList rbltypelist = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rblPurchaseType");
RadioButtonList rblpurchasedlist = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rblmPurchasedType");
TextBox tbPrevOnwerName = (TextBox)Repeater2.Items[rowIndex].FindControl("txtPrevOnwerName");
TextBox tbprevAddr = (TextBox)Repeater2.Items[rowIndex].FindControl("txtprevAddr");
TextBox tbprevCity = (TextBox)Repeater2.Items[rowIndex].FindControl("txtprevCity");
DropDownList tbPrevState = (DropDownList)Repeater2.Items[rowIndex].FindControl("ddlPrevState");
TextBox tbprevzip = (TextBox)Repeater2.Items[rowIndex].FindControl("txtprevzip");
TextBox tbmPrevOnwerName = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmPrevOnwerName");
TextBox tbmprevAddr = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmprevAddr");
TextBox tbmprevCity = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmprevCity");
DropDownList tbmPrevState = (DropDownList)Repeater2.Items[rowIndex].FindControl("ddlmPrevState");
TextBox tbmprevzip = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmprevzip");
TextBox tbbuyername = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyername");
TextBox tbbuyeraddress = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyeraddress");
TextBox tbbuyercity = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyercity");
DropDownList tbbuyerstate = (DropDownList)Repeater2.Items[rowIndex].FindControl("lblbuyerstate");
TextBox tbbuyerzip = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyerzip");
TextBox txtdatesold = (TextBox)Repeater2.Items[rowIndex].FindControl("txtdatesold");
TextBox tbsalePrice = (TextBox)Repeater2.Items[rowIndex].FindControl("txtsalePrice");
TextBox tbDescription = (TextBox)Repeater2.Items[rowIndex].FindControl("txtDescription");
TextBox tbmbuyername = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmbuyername");
TextBox tbmbuyeraddress = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmbuyeraddress");
TextBox tbmbuyercity = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmbuyercity");
DropDownList tbmbuyerstate = (DropDownList)Repeater2.Items[rowIndex].FindControl("lblmbuyerstate");
TextBox tbmbuyerzip = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmbuyerzip");
TextBox tbmdatesold = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmdatesold");
TextBox tbmsalePrice = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmsalePrice");
TextBox tbmDescription = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmDescription");
TextBox tbboatCost = (TextBox)Repeater2.Items[rowIndex].FindControl("boatCost");
TextBox tbmotorCost = (TextBox)Repeater2.Items[rowIndex].FindControl("motorCost");
RadioButtonList rbllist1 = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rblIssues");
TextBox tbfunctionalIsses = (TextBox)Repeater2.Items[rowIndex].FindControl("functionalIsses");
RadioButtonList rbllist2 = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("mrblIssues");
TextBox tbmfunctionalIsses = (TextBox)Repeater2.Items[rowIndex].FindControl("mfunctionalIsses");
TextBox tbvesseltypeUse = (TextBox)Repeater2.Items[rowIndex].FindControl("txtvesseltypeUse");
TextBox tbvesselname = (TextBox)Repeater2.Items[rowIndex].FindControl("txtvesselname");
TextBox tbvessellength = (TextBox)Repeater2.Items[rowIndex].FindControl("txtvessellength");
TextBox tbvesselYrBult = (TextBox)Repeater2.Items[rowIndex].FindControl("txtvesselYrBult");
TextBox tbVesselHullMateria = (TextBox)Repeater2.Items[rowIndex].FindControl("txtVesselHullMateria");
TextBox tbvesselhorsepEngine = (TextBox)Repeater2.Items[rowIndex].FindControl("vesselhorsepEngine");
TextBox tbcoastGuardNumber = (TextBox)Repeater2.Items[rowIndex].FindControl("coastGuardNumber");
TextBox txtVesselYrPurchased = (TextBox)Repeater2.Items[rowIndex].FindControl("txtVesselYrPurchased");
RadioButtonList PurchasedNew = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rblVPurchasedNew");
TextBox tbVesselPurchaseAmt = (TextBox)Repeater2.Items[rowIndex].FindControl("VesselPurchaseAmt");
TextBox tbtxthomePort = (TextBox)Repeater2.Items[rowIndex].FindControl("txthomePort");
TextBox tbtxtwhereDocked = (TextBox)Repeater2.Items[rowIndex].FindControl("txtwhereDocked");
TextBox tbbmequipAccessoryList = (TextBox)Repeater2.Items[rowIndex].FindControl("bmequipAccessoryList");
tbaircnty.Text = dt.Rows[i]["boatcnty"].ToString();
tbTextBox2.Text = dt.Rows[i]["aRegNo"].ToString();
tbaMake.Text = dt.Rows[i]["aMake"].ToString();
tbmMake.Text = dt.Rows[i]["mMake"].ToString();
tbaModelNo.Text = dt.Rows[i]["ModelNoA"].ToString();
tbmModelNo.Text = dt.Rows[i]["ModelNoM"].ToString();
tbboatYrBuilt.Text = dt.Rows[i]["boatYrBuilt"].ToString();
tbmotorYrBuilt.Text = dt.Rows[i]["motorYrBuilt"].ToString();
tbblength.Text = dt.Rows[i]["blength"].ToString();
tbhullmaterial.Text = dt.Rows[i]["hullmaterial"].ToString();
tbmhorsepower.Text = dt.Rows[i]["mhorsepower"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[i]["rdlmhorsepType"].ToString()))
{
rblhoreslist.Items.FindByText(dt.Rows[i]["rdlmhorsepType"].ToString()).Selected = true;
}
tbdatePurchased.Text = dt.Rows[i]["datePurchased"].ToString();
tbrbmdatePurchased.Text = dt.Rows[i]["mdatePurchased"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[i]["PurchaseType"].ToString()))
{
rbltypelist.Items.FindByText(dt.Rows[i]["PurchaseType"].ToString()).Selected = true;
}
if (!string.IsNullOrEmpty(dt.Rows[i]["rblmPurchasedType"].ToString()))
{
rblpurchasedlist.Items.FindByText(dt.Rows[i]["rblmPurchasedType"].ToString()).Selected = true;
}
tbPrevOnwerName.Text = dt.Rows[i]["PrevOnwerName"].ToString();
tbprevAddr.Text = dt.Rows[i]["prevAddr"].ToString();
tbprevCity.Text = dt.Rows[i]["prevCity"].ToString();
tbPrevState.Text = dt.Rows[i]["PrevState"].ToString();
tbprevzip.Text = dt.Rows[i]["prevzip"].ToString();
tbmPrevOnwerName.Text = dt.Rows[i]["mPrevOnwerName"].ToString();
tbmprevAddr.Text = dt.Rows[i]["mprevAddr"].ToString();
tbmprevCity.Text = dt.Rows[i]["mprevCity"].ToString();
tbmprevzip.Text = dt.Rows[i]["mprevzip"].ToString();
tbbuyername.Text = dt.Rows[i]["buyername"].ToString();
tbbuyeraddress.Text = dt.Rows[i]["buyeraddress"].ToString();
tbbuyercity.Text = dt.Rows[i]["buyercity"].ToString();
tbbuyerstate.Text = dt.Rows[i]["buyerstate"].ToString();
tbbuyerzip.Text = dt.Rows[i]["buyerzip"].ToString();
txtdatesold.Text = dt.Rows[i]["datesold"].ToString();
tbsalePrice.Text = dt.Rows[i]["salePrice"].ToString();
tbDescription.Text = dt.Rows[i]["Description"].ToString();
tbmbuyername.Text = dt.Rows[i]["mbuyername"].ToString();
tbmbuyeraddress.Text = dt.Rows[i]["mbuyeraddress"].ToString();
tbmbuyerstate.Text = dt.Rows[i]["mbuyerstate"].ToString();
tbmbuyerzip.Text = dt.Rows[i]["mbuyerzip"].ToString();
tbmdatesold.Text = dt.Rows[i]["mdatesold"].ToString();
tbmsalePrice.Text = dt.Rows[i]["msalePrice"].ToString();
tbmDescription.Text = dt.Rows[i]["mDescription"].ToString();
tbboatCost.Text = dt.Rows[i]["boatCost"].ToString();
tbmotorCost.Text = dt.Rows[i]["motorCost"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[i]["rblIssues"].ToString()))
{
rbllist1.Items.FindByText(dt.Rows[i]["rblIssues"].ToString()).Selected = true;
}
tbfunctionalIsses.Text = dt.Rows[i]["functionalIsses"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[i]["mrblIssues"].ToString()))
{
rbllist2.Items.FindByText(dt.Rows[i]["mrblIssues"].ToString()).Selected = true;
}
tbmfunctionalIsses.Text = dt.Rows[i]["mfunctionalIsses"].ToString();
tbvesseltypeUse.Text = dt.Rows[i]["vesseltypeUse"].ToString();
tbvesselname.Text = dt.Rows[i]["vesselname"].ToString();
tbvessellength.Text = dt.Rows[i]["vessellength"].ToString();
tbvesselYrBult.Text = dt.Rows[i]["vesselYrBult"].ToString();
tbVesselHullMateria.Text = dt.Rows[i]["VesselHullMateria"].ToString();
tbvesselhorsepEngine.Text = dt.Rows[i]["vesselhorsepEngine"].ToString();
tbcoastGuardNumber.Text = dt.Rows[i]["coastGuardNumber"].ToString();
txtVesselYrPurchased.Text = dt.Rows[i]["VesselYrPurchased"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[i]["PurchasedNew"].ToString()))
{
PurchasedNew.Items.FindByText(dt.Rows[i]["PurchasedNew"].ToString()).Selected = true;
}
tbVesselPurchaseAmt.Text = dt.Rows[i]["VesselPurchaseAmt"].ToString();
tbtxthomePort.Text = dt.Rows[i]["homePort"].ToString();
tbtxtwhereDocked.Text = dt.Rows[i]["whereDocked"].ToString();
tbbmequipAccessoryList.Text = dt.Rows[i]["bmequipAccessoryList"].ToString();
if (dt.Rows.Count - 1 == i)
{
tbTextBox2.Text = registerNumber;
tbcoastGuardNumber.Text = bregisterNumber;
}
rowIndex++;
}
}
}
}
Thank you very much.
God was on my side yesterday as management cancelled the scheduled demo due to other commitments.
|
|
|
|
|
There's nothing in that code which would cause that compiler error. Which line does the error refer to?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The error is on this line:
SetPreviousData2(registerNumber, bregisterNumber);
I don't know if it is because is it not being called by another method.
When I tested yesterday even before I added all the codes, I was able to go to the next page (Repeater2) and the two values for AregNo from MarineRegNo and coastGuardNumber from VesselRegNo were there.
Then that error started.
By the way, I did remove the if=== block you told me to remove yesterday.
It turned out that I was getting those errors from SetInitialRow2() because I forgot to remove that method and that method was calling SetPreviousData() methos.
|
|
|
|
|
samflex wrote: I don't know if it is because is it not being called by another method.
What do you mean by that?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
What I meant was that before, I was calling it inside AddNewRow2 method.
This error, I think started after I removed the AddNewRow2 method.
If I comment that line:
SetPreviousData2(registerNumber, bregisterNumber), then when click the NEXT button, the page is blank.
It may be that it is no longer needed but something is breaking the page.
|
|
|
|
|
Ok, I think the problem is here, not necessarily your problem but I may have missed something here because right now, when I click the NEXT page, it loads the form correctly except that the value of MarineRegNo and VesselRegNo in Repeater1 that were to populate AregNo and coastGuardNumber respectively, are not populating them.
Could it be in this method?
YEAR - FOUND IT!!
I had AregNo and coastGuardNumber twice, one empty and the other not.
NOW, when I enter values for Repeater1, they appear in Repeater2, YEAAA.
The real which I am about to try now is when I submit the data and try to populate the form with the account number, will the data I submitted load?
You are so gifted, I gush with jealousy.
private void PopulateRecord(DataTable table1)
{
DataTable table2 = LoadTable2(true);
table2.Rows.Clear();
foreach (DataRow row in table1.Rows)
{
DataRow dr = table2.NewRow();
dr["RowNumber"] = table2.Rows.Count + 1;
dr["aRegNo"] = row["MarineRegNo"];
dr["coastGuardNumber"] = row["VesselRegNo"];
dr["boatcnty"] = string.Empty;
dr["ARegNo"] = string.Empty;
dr["aMake"] = string.Empty;
dr["mMake"] = string.Empty;
dr["ModelNoA"] = string.Empty;
dr["ModelNoM"] = string.Empty;
dr["boatYrBuilt"] = string.Empty;
dr["motorYrBuilt"] = string.Empty;
dr["blength"] = string.Empty;
dr["hullmaterial"] = string.Empty;
dr["mhorsepower"] = string.Empty;
dr["rdlmhorsepType"] = string.Empty;
dr["datePurchased"] = string.Empty;
dr["mdatePurchased"] = string.Empty;
dr["PurchaseType"] = string.Empty;
dr["rblmPurchasedType"] = string.Empty;
dr["PrevOnwerName"] = string.Empty;
dr["prevAddr"] = string.Empty;
dr["prevCity"] = string.Empty;
dr["PrevState"] = string.Empty;
dr["prevzip"] = string.Empty;
dr["mPrevOnwerName"] = string.Empty;
dr["mprevAddr"] = string.Empty;
dr["mprevCity"] = string.Empty;
dr["mPrevState"] = string.Empty;
dr["mprevzip"] = string.Empty;
dr["buyername"] = string.Empty;
dr["buyeraddress"] = string.Empty;
dr["buyercity"] = string.Empty;
dr["buyerstate"] = string.Empty;
dr["buyerzip"] = string.Empty;
dr["datesold"] = string.Empty;
dr["salePrice"] = string.Empty;
dr["Description"] = string.Empty;
dr["mbuyername"] = string.Empty;
dr["mbuyeraddress"] = string.Empty;
dr["mbuyercity"] = string.Empty;
dr["mbuyerstate"] = string.Empty;
dr["mbuyerzip"] = string.Empty;
dr["mdatesold"] = string.Empty;
dr["msalePrice"] = string.Empty;
dr["mDescription"] = string.Empty;
dr["boatCost"] = string.Empty;
dr["motorCost"] = string.Empty;
dr["rblIssues"] = string.Empty;
dr["functionalIsses"] = string.Empty;
dr["mrblIssues"] = string.Empty;
dr["mfunctionalIsses"] = string.Empty;
dr["vesseltypeUse"] = string.Empty;
dr["vesselname"] = string.Empty;
dr["vessellength"] = string.Empty;
dr["vesselYrBult"] = string.Empty;
dr["VesselHullMateria"] = string.Empty;
dr["vesselhorsepEngine"] = string.Empty;
dr["coastGuardNumber"] = string.Empty;
dr["VesselYrPurchased"] = string.Empty;
dr["PurchasedNew"] = string.Empty;
dr["VesselPurchaseAmt"] = string.Empty;
dr["homePort"] = string.Empty;
dr["whereDocked"] = string.Empty;
dr["bmequipAccessoryList"] = string.Empty;
table2.Rows.Add(dr);
}
Repeater2.DataSource = table2;
Repeater2.DataBind();
foreach (RepeaterItem item in Repeater2.Items)
{
((Button)item.FindControl("BtnAdd2")).Visible = table2.Rows.Count > 1;
((Button)item.FindControl("btnDelete2")).Visible = table2.Rows.Count > 1;
}
}
|
|
|
|
|
I am sorry for the bad news sir but I am getting nullReference exception on the following markup:
<%foreach (System.Data.DataRow row in dtAirInfoTable.Rows)
{%>
<tr>
<td>
<%=row.ItemArray[1].ToString()%>
</td>
<td align="center">
<%=row.ItemArray[2].ToString()%>
</td>
</tr>
<tr>
<td>
<%=row.ItemArray[3].ToString()%>
</td>
<td align="center">
<%=row.ItemArray[4].ToString()%>
</td>
</tr>
<% } %>
I used to have this line:
ViewState["TempData"] = dtCurrentTable;
on the OnClickNext method but it has changed and that line is no longer there.
Then on another method, I would reference it thus:
public DataTable dtAirInfoTable;
lblTotalPrev.Text = hfvalue.Value;
if (ViewState["TempData"] != null)
{
dtAirInfoTable = (DataTable)ViewState["TempData"];
}
This would allow me to display the values from these:
TextBox tbboatregNum = (TextBox)item.FindControl("txtboatregNum");
TextBox tbPayerret = (TextBox)item.FindControl("txtPayerret");
TextBox tbCGvesselNum = (TextBox)item.FindControl("cgaurdNumber");
TextBox tbCGtaxpayerret = (TextBox)item.FindControl("cguardreturnedval");
DataRow row = dt.Rows[rowIndex];
row["MarineRegNo"] = tbboatregNum.Text;
row["TaxPyrRetdVal"] = tbPayerret.Text;
row["VesselRegNo"] = tbCGvesselNum.Text;
row["VesselTaxPyrRetdVal"] = tbCGtaxpayerret.Text;
and display their total in this line:
lblTotal.Text = hfvalue.Value;
|
|
|
|
|
If you haven't set the default values for the columns, then the value will be null . Calling .ToString() on a null value will throw a NullReferenceException . Either set the default values for the columns, or use Convert.ToString(row.ItemArray[1]) .
As far as I can see, "TempData" was only ever set to the first table; in which case, you can replace it with:
lblTotalPrev.Text = hfvalue.Value;
dtAirInfoTable = LoadTable1(false);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Everything looks great sir.
I am able to enter data on Repeater1 and those that need to appear in Repeater2 are appearing correctly.
The issue I have had in the past is that I would go through this process to insert records into the database successfully but when I try inserting another record, it is blind.
I am confident it is all fixed up now but I want to be sure when I go all the way to insert into the database but I am not able to do so because of an unrelated bug I am trying to resolve.
Once that is resolve, I will post a feedback.
Thanks so much Richard.
You have come through for me so many times. This is huge.
|
|
|
|
|
Hi Richard, well goodness, bad news scenario here.
I was able to successfully insert records into the database.
So, this is great. Thank you again.
Bad news is that when I attempt to populate the form with the records I inserted, I get the following:
Input string was not in a correct format.
That's because that field is empty:
dr["boatYrBuilt"] = string.Empty;
When I added value from the stored procedure I built to populate them shown below,
dr["boatYrBuilt"] = row["boatYrBuilt"];
dr["motorYrBuilt"] = row["Motor_Year_Built"];
I get Column 'boatYrBuilt' does not belong to table Table1.
To assign the values similar to this:
dr["coastGuardNumber"] = row["VesselRegNo"];
where does VesselRegNo come from?
I am sure the rest will give similar errors.
I was under the impression that as long the field name from the stored proc is assigned as Eval on Markup, this issue will not exist.
modified 22-Sep-17 15:48pm.
|
|
|
|
|
samflex wrote: Input string was not in a correct format.
On which line?
samflex wrote: Column 'boatYrBuilt' does not belong to table Table1
Which table are you updating? From what I can see, that should be the second table, and you should be creating the column in the LoadTable2 method.
samflex wrote: where does VesselRegNo come from?
dr is the new row in the second table; row is the row in the first table.
In the OnClickNext method, you copy the text from the cgaurdNumber control to the VesselRegNo column in the row from the first table.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The error is coming from populateRecord method. I went back and looked at your solution, I believe I am using the code correctly. I am pasting here again just so you can take a look.
Sorry sir.
ivate void PopulateRecord(DataTable table1)
{
DataTable table2 = LoadTable2(true);
table2.Rows.Clear();
foreach (DataRow row in table1.Rows)
{
DataRow dr = table2.NewRow();
dr["RowNumber"] = table2.Rows.Count + 1;
dr["aRegNo"] = row["MarineRegNo"];
dr["coastGuardNumber"] = row["VesselRegNo"];
dr["boatcnty"] = string.Empty;
dr["aMake"] = string.Empty;
dr["mMake"] = string.Empty;
dr["ModelNoA"] = string.Empty;
dr["ModelNoM"] = string.Empty;
dr["boatYrBuilt"] = string.Empty;
dr["motorYrBuilt"] = string.Empty;
dr["blength"] = string.Empty;
dr["hullmaterial"] = string.Empty;
dr["mhorsepower"] = string.Empty;
dr["rdlmhorsepType"] = string.Empty;
dr["datePurchased"] = string.Empty;
dr["mdatePurchased"] = string.Empty;
dr["PurchaseType"] = string.Empty;
dr["rblmPurchasedType"] = string.Empty;
dr["PrevOnwerName"] = string.Empty;
dr["prevAddr"] = string.Empty;
dr["prevCity"] = string.Empty;
dr["PrevState"] = string.Empty;
dr["prevzip"] = string.Empty;
dr["mPrevOnwerName"] = string.Empty;
dr["mprevAddr"] = string.Empty;
dr["mprevCity"] = string.Empty;
dr["mPrevState"] = string.Empty;
dr["mprevzip"] = string.Empty;
dr["buyername"] = string.Empty;
dr["buyeraddress"] = string.Empty;
dr["buyercity"] = string.Empty;
dr["buyerstate"] = string.Empty;
dr["buyerzip"] = string.Empty;
dr["datesold"] = string.Empty;
dr["salePrice"] = string.Empty;
dr["Description"] = string.Empty;
dr["mbuyername"] = string.Empty;
dr["mbuyeraddress"] = string.Empty;
dr["mbuyercity"] = string.Empty;
dr["mbuyerstate"] = string.Empty;
dr["mbuyerzip"] = string.Empty;
dr["mdatesold"] = string.Empty;
dr["msalePrice"] = string.Empty;
dr["mDescription"] = string.Empty;
dr["boatCost"] = string.Empty;
dr["motorCost"] = string.Empty;
dr["rblIssues"] = string.Empty;
dr["functionalIsses"] = string.Empty;
dr["mrblIssues"] = string.Empty;
dr["mfunctionalIsses"] = string.Empty;
dr["vesseltypeUse"] = string.Empty;
dr["vesselname"] = string.Empty;
dr["vessellength"] = string.Empty;
dr["vesselYrBult"] = string.Empty;
dr["VesselHullMateria"] = string.Empty;
dr["vesselhorsepEngine"] = string.Empty;
dr["VesselYrPurchased"] = string.Empty;
dr["PurchasedNew"] = string.Empty;
dr["VesselPurchaseAmt"] = string.Empty;
dr["homePort"] = string.Empty;
dr["whereDocked"] = string.Empty;
dr["bmequipAccessoryList"] = string.Empty;
table2.Rows.Add(dr);
}
Repeater2.DataSource = table2;
Repeater2.DataBind();
foreach (RepeaterItem item in Repeater2.Items)
{
((Button)item.FindControl("BtnAdd2")).Visible = table2.Rows.Count > 1;
((Button)item.FindControl("btnDelete2")).Visible = table2.Rows.Count > 1;
}
}
|
|
|
|
|
There isn't anything in that which would throw an "Input string was not in a correct format" exception.
Are you sure it's not related to the markup for Repeater2 ?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Here is an example of how I am using these fields in Repeater2.
<td style="white-space: nowrap;">
Year Built:<asp:TextBox ID="boatYrBuilt" Text='<%#Eval("boatYrBuilt")%>' Style="width: 270px; margin-left: 250px;" runat="server"></asp:TextBox>
</td>
This happens only when I when I enter an account number to try to populate the form after tne records have been created.
The error does not occur when creating a new record, only when trying to pull an existing record.
|
|
|
|
|
Once again, there's nothing in the code you've shown which would produce the exception. You'll need to debug your code to find out where the exception is being thrown from.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry to keep coming back sir.
Unless, I am not debugging this correctly, when I tried debugging, it keeps breaking on Repeater1 but shows boatYrBuilt as the culprit even though it is likely to not be the issue.
In other words, I enter account number, click enter and it loads page 1 which has personal info like name, phone, address, etc.
Then as soon as I click Next (to go to page2 which is Repeater1), it throws the incorrect format string error.
Could it be these?
<ItemTemplate>
<tr>
<td>
<asp:TextBox ID="txtboatregNum" Text='<%# Eval("MarineRegNo") %>' runat="server" placeholder="Enter registration #..." Style="width: 450px;" class="form-control"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="txtPayerret" Text='<%# Eval("TaxPyrRetdVal") %>' runat="server" placeholder="Enter Taxpayer returned value as of Jan. 1..." Style="width: 400px;" class="form-control txtPayerret"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="cgaurdNumber" Text='<%# Eval("VesselRegNo") %>' runat="server" placeholder="Enter Coast Guard #..." Style="width: 450px;" class="form-control"></asp:TextBox>
</td>
<td>
<asp:TextBox ID="cguardreturnedval" Text='<%# Eval("VesselTaxPyrRetdVal") %>' runat="server" placeholder="Enter Taxpayer returned value as of Jan. 1..." Style="width: 400px;" class="form-control txtPayerret"></asp:TextBox>
</td>
<td>
<asp:Button ID="BtnAdd" Style="width: 150px;" runat="server" Text="Next Boat"
OnClick="BtnAdd_Click" CssClass="btnclass" />
<asp:Button ID="btnDelete" Style="width: 120px;" runat="server" Text="Remove a row"
OnClick="btnDelete_Click" CommandArgument='<%# Container.ItemIndex %>' CssClass="btnclass" />
</td>
</tr>
</ItemTemplate>
I am just grabbing at straws now.
|
|
|
|
|
The exception will include a stack trace. There may be some framework code at the top, but as you read down it, you should eventually find something that relates to your code.
The first item which refers to your code will tell you the file and the line which triggered the exception.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I know you have been very patient with me and you have given me more than I asked for (Thank you) but can you please look at the below code for me?
The problem I believe, is that when I enter an account number, it is not populating the form.
Could you please see if there is something to change with the code below?
TER PROCEDURE [dbo].[sp_AllRecs]
@pin int
AS
BEGIN
SET NOCOUNT ON;
SELECT ROW_Number() OVER (ORDER BY(SELECT 0)) RowNumber, mp.[DateSold] as datesold
,mp.[SalePrice] as salePrice
,mp.[Description] as Description
,mp.[BuyerFullName] as buyername
,mp.[BuyerAddress] as buyeraddress
,mp.[BuyerCity] as buyercity
,mp.[BuyerState] as buyerstate
,mp.[BuyerZipCode] as buyerzip
,mp.[mDateSold] as mdatesold
,mp.[mSalePrice] as msalePrice
,mp.[mDescription] as mDescription
,mp.[mBuyerFullName] as mbuyername
,mp.[mBuyerAddress] as mbuyeraddress
,mp.[mBuyerCity] as mbuyercity
,mp.[mBuyerState] as mbuyerstate
,mp.[mBuyerZipCode] as mbuyerzip
,mp.[PreviousOwnerName] as PrevOnwerName
,mp.[PreviousOwnerAddress] as prevAddr
,mp.[PreviousOwnerCity] as prevCity
,mp.[PreviousOwnerState] as PrevState
,mp.[PreviousOwnerZipCode] as prevzip
,mp.[mPreviousOwnerName] as mprevOnwerName
,mp.[mPreviousOwnerAddress] as mprevAddr
,mp.[mPreviousOwnerCity] as mprevCity
,mp.[mPreviousOwnerState] as mPrevState
,mp.[mPreviousOwnerZipCode] as mprevzip
,mp.[signDate]
,mp.[sTitle]
,ms.County As boatcnty
,ms.Registration_No As aRegNo
,ms.Motor_MFG_Make AS aMake
,ms.Boat_MFG_Make as mMake
,ms.Motor_MFG_Model as ModelNoA
,ms.Boat_MFG_Model as ModelNoM
,ms.Boat_Year_Built as boatYrBuilt
,ms.Motor_Year_Built as motorYrBuilt
,ms.[Length] as blength
,ms.HullMaterial as hullmaterial
,ms.HorsePower as mhorsepower
,ISNULL(ms.HorsePowerType,'NA') as rdlmhorsepType
,ms.Boat_DatePurchased as datePurchased
,ms.Motor_DatePurchased as mdatePurchased
,ISNULL(ms.Boat_PurchaseType,'NA') as PurchaseType
,ms.Motor_PurchaseType as rblmPurchasedType
,ms.MotorCost as motorCost
,ms.BoatCost as boatCost
,ms.FileDate
,ms.boatIssues as rblIssues
,ms.motorIssues as mrblIssues
,ms.boatIssuesDetails as functionalIsses
,ms.motorIssuesDetails as mfunctionalIsses
,mf.TypeOfVessel as vesseltypeUse
,mf.VesselName as vesselname
,mf.HorspwrTypOfEngine as vesselhorsepEngine
,mf.CoastGuardNo AS coastGuardNumber
,mf.YearPurchased as VesselYrPurchased
,mf.PurchaseType as PurchasedNew
,mf.AmtOfPurchase as VesselPurchaseAmt
,mf.HomePort as homePort
,mf.WhereDocked as whereDocked
,mf.Boat_Motor_Accsry_Equip as bmequipAccessoryList
,mf.vesselLength as vessellength
,mf.YrVesselBuilt as vesselYrBult
,mf.VHullMaterial as VesselHullMateria
FROM MarineInfo m
INNER JOIN BoatMarincePurchaserInfo mp ON m.pid = mp.pid
INNER JOIN MarineScheduleD ms ON m.pid = ms.pid
INNER JOIN MarineFedVesselInfo mf ON m.pid = mf.pid
WHERE m.pid = @pin
END
C#
private void getRecs(int pin)
{
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("sp_AllRecs", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p1 = new SqlParameter("@pin", pin);
cmd.Parameters.Add(p1);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dtPrevRecords = new DataTable();
sda.Fill(dtPrevRecords);
if (dtPrevRecords.Rows.Count > 0)
{
Repeater2.DataSource = dtPrevRecords;
Repeater2.DataBind();
ViewState["CurrentTable"] = dtPrevRecords;
}
}
pageLoad() event
if (!Page.IsPostBack)
{
this.getRecs(pid);
}
|
|
|
|
|
There's nothing obviously wrong with that code. Have you tried running the query in SQL Server Management Studio, to make sure you're getting the right data back?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, I have run it in SSMS and it displayed the correct data but geez why it is not displaying on the form is beyond me.
|
|
|
|
|
Just for my sanity, it is C# that calls the SP and references CurrentTable datatable correct?
private void getRecs(int pin)
{
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("sp_AllRecs", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p1 = new SqlParameter("@pin", pin);
cmd.Parameters.Add(p1);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dtPrevRecords = new DataTable();
sda.Fill(dtPrevRecords);
if (dtPrevRecords.Rows.Count > 0)
{
Repeater2.DataSource = dtPrevRecords;
Repeater2.DataBind();
ViewState["CurrentTable"] = dtPrevRecords;
}
}
Something should be referencing PopulateRecord method to populate those values and load them to the form and that is not happening.
|
|
|
|
|
That replaces the second table; it doesn't read anything from it.
The PopulateRecord method is called from OnClickNext , so long as certain conditions have been met:
protected void OnClickNext(object sender, EventArgs e)
{
DataTable dt = LoadTable1(false);
if (dt != null)
{
...
myMultiView.ActiveViewIndex += 1;
if (myMultiView.ActiveViewIndex != 3)
{
PopulateRecord(dt);
}
}
}
Those conditions are the same as in the code you posted[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry, I am going to stop bothering you after this question.
You have given me more than enough of your time and assistance.
So, as far as the OnClickNext() method is concerned, the only conditions that have to be met are that those four form fields have values which they do.
Am I missing some other conditions that have to be met from that method?
modified 9-Oct-17 11:11am.
|
|
|
|
|