|
I'm not sure I'm following exactly what you're doing, but I'd be inclined to start by tidying up the code:
private DataTable LoadTable1(bool createIfMissing)
{
const string ViewStateKey = "CurrTable";
DataTable dt = ViewState[ViewStateKey] as DataTable;
if (createIfMissing)
{
if (dt == null)
{
dt = new DataTable();
dt.Columns.Add(new DataColumn("ID", typeof(string)));
dt.Columns.Add(new DataColumn("MarineRegNo", typeof(string)));
dt.Columns.Add(new DataColumn("TaxPyrRetdVal", typeof(string)));
dt.Columns.Add(new DataColumn("VesselRegNo", typeof(string)));
dt.Columns.Add(new DataColumn("VesselTaxPyrRetdVal", typeof(string)));
ViewState[ViewStateKey] = dt;
}
if (dt.Rows.Count == 0)
{
DataRow dr = dt.NewRow();
dr["ID"] = 1;
dr["MarineRegNo"] = string.Empty;
dr["TaxPyrRetdVal"] = string.Empty;
dr["VesselRegNo"] = string.Empty;
dr["VesselTaxPyrRetdVal"] = string.Empty;
dt.Rows.Add(dr);
}
}
return dt;
}
private void SetInitialRow()
{
myMultiView.ActiveViewIndex = 0;
DataTable dt = LoadTable1(true);
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
private DataTable LoadTable2(bool createIfMissing)
{
const string ViewStateKey = "CurrentTable";
DataTable dt = ViewState[ViewStateKey] as DataTable;
if (dt == null && createIfMissing)
{
dt = new DataTable();
dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dt.Columns.Add(new DataColumn("boatcnty", typeof(string)));
dt.Columns.Add(new DataColumn("aRegNo", typeof(string)));
...
ViewState[ViewStateKey] = dt;
}
return dt;
}
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"];
...
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;
}
}
protected void OnClickNext(object sender, EventArgs e)
{
DataTable dt = LoadTable1(false);
if (dt != null)
{
if (dt.Rows.Count != 0)
{
int rowIndex = 0;
foreach (RepeaterItem item in Repeater1.Items)
{
switch (item.ItemType)
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
case ListItemType.SelectedItem:
case ListItemType.EditItem:
{
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;
rowIndex++;
break;
}
}
}
}
myMultiView.ActiveViewIndex += 1;
if (myMultiView.ActiveViewIndex != 3)
{
PopulateRecord(dt);
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 21-Sep-17 13:29pm.
|
|
|
|
|
Thank you very much Richard.
I think I got what you are trying to do but it is complaining about registerNumber assigned to ARegNo and bRegisterNumber assigned to coastGuardNumber.
The reason I am having this issue is because we want out users to be able to enter an account number and populate both Repeater1 and Repeater2 if record exists and the reason we want users to enter an account to populate those controls is because they have to complete a form but the form is too long.
So, we broke the form down into 4 pages with page 4 being preview page.
So, user can complete page one, click a button to save and continue later.
When they come back later, they want to know where they stopped.
I don't know if I am still making sense.
modified 21-Sep-17 13:02pm.
|
|
|
|
|
You'd still need to call SetInitialRow , but you shouldn't need to call SetInitialRow2 .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am just running into many bugs.
First, registerNumber which is assigned to ARegNo is not being recognized.
bregisterNumber which is assigned to coastGuardNumber is not being recorgnized.
Also, dr["ID"] = 1; on populateRecord function is not being recognized.
Thanks for your help sir.
|
|
|
|
|
Aside from a typo in the LoadTable2 function, where I was using dts instead of dt , there shouldn't be any compiler errors with the code I posted.
The code I posted doesn't contain either registerNumber or bregisterNumber .
And the PopulateRecord method I posted doesn't contain dr["ID"] = 1; anywhere.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That's true sir but the error came up because I added the rest of the code for SetInitialRow2() unless you asking me to use only the ones you posted.
If so, how do I handle the rest because they are supposed to populate Repeater2 when user enters an account number just like MarineRegNo and the other 3 that came with SetInitialRow()
Here is the complete code for SetInitialRow2(). I posted entire code yesterday.
Thanks so much for all your help.
private void SetInitialRow2(string registerNumber, string bregisterNumber)
{
DataTable dta;
if (ViewState["CurrentTable"] == null)
{
dta = new DataTable();
DataRow dr = null;
dta.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dta.Columns.Add(new DataColumn("boatcnty", typeof(string)));
dta.Columns.Add(new DataColumn("aRegNo", typeof(string)));
dta.Columns.Add(new DataColumn("aMake", typeof(string)));
dta.Columns.Add(new DataColumn("mMake", typeof(string)));
dta.Columns.Add(new DataColumn("ModelNoA", typeof(string)));
dta.Columns.Add(new DataColumn("ModelNoM", typeof(string)));
dta.Columns.Add(new DataColumn("boatYrBuilt", typeof(string)));
dta.Columns.Add(new DataColumn("motorYrBuilt", typeof(string)));
dta.Columns.Add(new DataColumn("blength", typeof(string)));
dta.Columns.Add(new DataColumn("hullmaterial", typeof(string)));
dta.Columns.Add(new DataColumn("mhorsepower", typeof(string)));
dta.Columns.Add(new DataColumn("rdlmhorsepType", typeof(string)));
dta.Columns.Add(new DataColumn("datePurchased", typeof(string)));
dta.Columns.Add(new DataColumn("mdatePurchased", typeof(string)));
dta.Columns.Add(new DataColumn("PurchaseType", typeof(string)));
dta.Columns.Add(new DataColumn("rblmPurchasedType", typeof(string)));
dta.Columns.Add(new DataColumn("PrevOnwerName", typeof(string)));
dta.Columns.Add(new DataColumn("prevAddr", typeof(string)));
dta.Columns.Add(new DataColumn("prevCity", typeof(string)));
dta.Columns.Add(new DataColumn("PrevState", typeof(string)));
dta.Columns.Add(new DataColumn("prevzip", typeof(string)));
dta.Columns.Add(new DataColumn("mPrevOnwerName", typeof(string)));
dta.Columns.Add(new DataColumn("mprevAddr", typeof(string)));
dta.Columns.Add(new DataColumn("mprevCity", typeof(string)));
dta.Columns.Add(new DataColumn("mPrevState", typeof(string)));
dta.Columns.Add(new DataColumn("mprevzip", typeof(string)));
dta.Columns.Add(new DataColumn("buyername", typeof(string)));
dta.Columns.Add(new DataColumn("buyeraddress", typeof(string)));
dta.Columns.Add(new DataColumn("buyercity", typeof(string)));
dta.Columns.Add(new DataColumn("buyerstate", typeof(string)));
dta.Columns.Add(new DataColumn("buyerzip", typeof(string)));
dta.Columns.Add(new DataColumn("datesold", typeof(string)));
dta.Columns.Add(new DataColumn("salePrice", typeof(string)));
dta.Columns.Add(new DataColumn("Description", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyername", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyeraddress", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyercity", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyerstate", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyerzip", typeof(string)));
dta.Columns.Add(new DataColumn("mdatesold", typeof(string)));
dta.Columns.Add(new DataColumn("msalePrice", typeof(string)));
dta.Columns.Add(new DataColumn("mDescription", typeof(string)));
dta.Columns.Add(new DataColumn("boatCost", typeof(string)));
dta.Columns.Add(new DataColumn("motorCost", typeof(string)));
dta.Columns.Add(new DataColumn("rblIssues", typeof(string)));
dta.Columns.Add(new DataColumn("functionalIsses", typeof(string)));
dta.Columns.Add(new DataColumn("mrblIssues", typeof(string)));
dta.Columns.Add(new DataColumn("mfunctionalIsses", typeof(string)));
dta.Columns.Add(new DataColumn("vesseltypeUse", typeof(string)));
dta.Columns.Add(new DataColumn("vesselname", typeof(string)));
dta.Columns.Add(new DataColumn("vessellength", typeof(string)));
dta.Columns.Add(new DataColumn("vesselYrBult", typeof(string)));
dta.Columns.Add(new DataColumn("VesselHullMateria", typeof(string)));
dta.Columns.Add(new DataColumn("vesselhorsepEngine", typeof(string)));
dta.Columns.Add(new DataColumn("coastGuardNumber", typeof(string)));
dta.Columns.Add(new DataColumn("VesselYrPurchased", typeof(string)));
dta.Columns.Add(new DataColumn("PurchasedNew", typeof(string)));
dta.Columns.Add(new DataColumn("VesselPurchaseAmt", typeof(string)));
dta.Columns.Add(new DataColumn("homePort", typeof(string)));
dta.Columns.Add(new DataColumn("whereDocked", typeof(string)));
dta.Columns.Add(new DataColumn("bmequipAccessoryList", typeof(string)));
dr = dta.NewRow();
dr["RowNumber"] = 1;
dr["boatcnty"] = string.Empty;
dr["ARegNo"] = registerNumber;
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"] = bregisterNumber;
dr["VesselYrPurchased"] = string.Empty;
dr["PurchasedNew"] = string.Empty;
dr["VesselPurchaseAmt"] = string.Empty;
dr["homePort"] = string.Empty;
dr["whereDocked"] = string.Empty;
dr["bmequipAccessoryList"] = string.Empty;
dta.Rows.Add(dr);
}
else
{
dta = (DataTable)ViewState["CurrentTable"];
}
ViewState["CurrentTable"] = dta;
if (dta.Rows.Count > 0)
{
Repeater2.DataSource = dta;
Repeater2.DataBind();
}
}
|
|
|
|
|
Don't use SetInitialRow2 or AddNewRow2 .
Add the missing columns in the LoadTable2 method, where I've put "…"; and add the missing row values in the PopulateRecord method, where I've put "…".
LoadTable2 will create the table if it doesn't exist, and store it in the view-state. PopulateRecord will create the rows in that table based on the other table, and bind Repeater2 to the result. The SetInitialRow2 and AddNewRow2 methods aren't needed.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You are such a genius!
This is incredible. You did all of this in a few minutes something I have been struggling with for days.
Even though I have not added all the records to PopulateRecord method, it is already beginning to populate MarineRegNo and the others to form.
Please bear with me for a few more questions.
On the LoadTable2 method, I am still getting error that registerNumber and bregisterNumber do not exist.
I will post entire LoadTable2 so you can tell me if I need to take that portion out.
private DataTable LoadTable2(bool createIfMissing)
{
const string ViewStateKey = "CurrentTable";
DataTable dt = ViewState[ViewStateKey] as DataTable;
if (dt == null && createIfMissing)
{
dt = new DataTable();
dta.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dta.Columns.Add(new DataColumn("boatcnty", typeof(string)));
dta.Columns.Add(new DataColumn("aRegNo", typeof(string)));
dta.Columns.Add(new DataColumn("aMake", typeof(string)));
dta.Columns.Add(new DataColumn("mMake", typeof(string)));
dta.Columns.Add(new DataColumn("ModelNoA", typeof(string)));
dta.Columns.Add(new DataColumn("ModelNoM", typeof(string)));
dta.Columns.Add(new DataColumn("boatYrBuilt", typeof(string)));
dta.Columns.Add(new DataColumn("motorYrBuilt", typeof(string)));
dta.Columns.Add(new DataColumn("blength", typeof(string)));
dta.Columns.Add(new DataColumn("hullmaterial", typeof(string)));
dta.Columns.Add(new DataColumn("mhorsepower", typeof(string)));
dta.Columns.Add(new DataColumn("rdlmhorsepType", typeof(string)));
dta.Columns.Add(new DataColumn("datePurchased", typeof(string)));
dta.Columns.Add(new DataColumn("mdatePurchased", typeof(string)));
dta.Columns.Add(new DataColumn("PurchaseType", typeof(string)));
dta.Columns.Add(new DataColumn("rblmPurchasedType", typeof(string)));
dta.Columns.Add(new DataColumn("PrevOnwerName", typeof(string)));
dta.Columns.Add(new DataColumn("prevAddr", typeof(string)));
dta.Columns.Add(new DataColumn("prevCity", typeof(string)));
dta.Columns.Add(new DataColumn("PrevState", typeof(string)));
dta.Columns.Add(new DataColumn("prevzip", typeof(string)));
dta.Columns.Add(new DataColumn("mPrevOnwerName", typeof(string)));
dta.Columns.Add(new DataColumn("mprevAddr", typeof(string)));
dta.Columns.Add(new DataColumn("mprevCity", typeof(string)));
dta.Columns.Add(new DataColumn("mPrevState", typeof(string)));
dta.Columns.Add(new DataColumn("mprevzip", typeof(string)));
dta.Columns.Add(new DataColumn("buyername", typeof(string)));
dta.Columns.Add(new DataColumn("buyeraddress", typeof(string)));
dta.Columns.Add(new DataColumn("buyercity", typeof(string)));
dta.Columns.Add(new DataColumn("buyerstate", typeof(string)));
dta.Columns.Add(new DataColumn("buyerzip", typeof(string)));
dta.Columns.Add(new DataColumn("datesold", typeof(string)));
dta.Columns.Add(new DataColumn("salePrice", typeof(string)));
dta.Columns.Add(new DataColumn("Description", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyername", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyeraddress", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyercity", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyerstate", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyerzip", typeof(string)));
dta.Columns.Add(new DataColumn("mdatesold", typeof(string)));
dta.Columns.Add(new DataColumn("msalePrice", typeof(string)));
dta.Columns.Add(new DataColumn("mDescription", typeof(string)));
dta.Columns.Add(new DataColumn("boatCost", typeof(string)));
dta.Columns.Add(new DataColumn("motorCost", typeof(string)));
dta.Columns.Add(new DataColumn("rblIssues", typeof(string)));
dta.Columns.Add(new DataColumn("functionalIsses", typeof(string)));
dta.Columns.Add(new DataColumn("mrblIssues", typeof(string)));
dta.Columns.Add(new DataColumn("mfunctionalIsses", typeof(string)));
dta.Columns.Add(new DataColumn("vesseltypeUse", typeof(string)));
dta.Columns.Add(new DataColumn("vesselname", typeof(string)));
dta.Columns.Add(new DataColumn("vessellength", typeof(string)));
dta.Columns.Add(new DataColumn("vesselYrBult", typeof(string)));
dta.Columns.Add(new DataColumn("VesselHullMateria", typeof(string)));
dta.Columns.Add(new DataColumn("vesselhorsepEngine", typeof(string)));
dta.Columns.Add(new DataColumn("coastGuardNumber", typeof(string)));
dta.Columns.Add(new DataColumn("VesselYrPurchased", typeof(string)));
dta.Columns.Add(new DataColumn("PurchasedNew", typeof(string)));
dta.Columns.Add(new DataColumn("VesselPurchaseAmt", typeof(string)));
dta.Columns.Add(new DataColumn("homePort", typeof(string)));
dta.Columns.Add(new DataColumn("whereDocked", typeof(string)));
dta.Columns.Add(new DataColumn("bmequipAccessoryList", typeof(string)));
ViewState[ViewStateKey] = dta;
}
if (dta.Rows.Count == 0)
{
DataRow dr = dta.NewRow();
dr["RowNumber"] = 1;
dr["boatcnty"] = string.Empty;
dr["ARegNo"] = registerNumber;
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"] = bregisterNumber;
dr["VesselYrPurchased"] = string.Empty;
dr["PurchasedNew"] = string.Empty;
dr["VesselPurchaseAmt"] = string.Empty;
dr["homePort"] = string.Empty;
dr["whereDocked"] = string.Empty;
dr["bmequipAccessoryList"] = string.Empty;
dta.Rows.Add(dr);
}
return dta;
}
The second question I have is that I see how you assigned values to MarineRegNo and VesselRegNo.
dr["RowNumber"] = table2.Rows.Count + 1;
dr["aRegNo"] = row["MarineRegNo"];
dr["coastGuardNumber"] = row["VesselRegNo"];
Do I need to assign values from the DB to the rest like instead of this:
dr["boatcnty"] = string.Empty;
I do this:
dr["boatcnty"] = row["boatcnty"];
row["boatcnty"] is db record.
Thanks so much Richard.
|
|
|
|
|
In LoadTable2 , take out the entire if (dta.Rows.Count == 0) { ... } block. The rows are created in the PopulateRecord function, based on the rows from the other table.
Whether or not you assign values to the empty columns in the new rows depends on how you're using those columns. If you don't assign a value, the default will be null . If you try to access the length of a value that's null , you'll get a NullReferenceException . But if all you're doing is binding the data using Bind or Eval , setting the column to string.Empty won't make any difference.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
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.
|
|
|
|
|