This is the code on the page: 1
String idx = "";
Idx = request. querystring ["idx"];
C_edititem = (edititem) page. loadcontrol ("productbarcodecontrols/edititem. ascx ");
C_edititem.pk_id = idx;
This. web_contaner.controls.add (c_edititem );
C_edititem.setrunningtype (actiontype. updatedbarcodeitem );
Here is the runingtype Code 2 in the user control.
Public void setrunningtype (string Rtype)
{
Switch (Rtype)
{
Case actiontype. updatedbarcodeitem:
Setlabletotext ();
Code_txt.editenable = false;
Action_pal.visible = true;
Add_btn.visible = false;
This. bindlist ();
Break;
Case actiontype. viewbarcodeitem:
Action_pal.visible = false;
This. bindlist ();
Break;
}
}
Here is code 3 for setting data.
Datarow ROW = This. mycode. getbarcodebyidx (this. pk_id );
Code_txt.text = row [barcodedata. code_field]. tostring ();
Partno_txt.text = row [barcodedata. partno_field]. tostring ();
Updatepartno_txt.text = row [barcodedata. newpartno_field]. tostring ();
Standardpartno_txt.text = row [barcodedata. standpartno_field]. tostring ();
Customer_txt.text = row [barcodedata. customer_field]. tostring ();
Status_rdb.selectedvalue = row [barcodedata. status_field]. tostring (). Trim (). tolower ();
Remark_txt.text = row [barcodedata. remark_field]. tostring ();
Labeltype_txt.text = row [barcodedata. labeltype_field]. tostring ();
Labledescritiop_txt.text = row [barcodedata. labeldescription_field]. tostring ();
Description_txt.text = row [barcodedata. description_field]. tostring ();
Updatedesc_txt.text = row [barcodedata. newdescription_field]. tostring ();
Here is code 4 updated after pressing update.
Datarow ROW = This. mycode. getbarcodebyidx (this. pk_id );
Row [barcodedata. partno_field] = partno_txt.text.trim ();
Row [barcodedata. newpartno_field] = updatepartno_txt.text.trim ();
Row [barcodedata. standpartno_field] = standardpartno_txt.text.trim ();
Row [barcodedata. customer_field] = customer_txt.text.trim ();
Row [barcodedata. status_field] = status_rdb.selectedvalue;
Row [barcodedata. remark_field] = remark_txt.text.trim ();
Row [barcodedata. labeltype_field] = labeltype_txt.text.trim ();
Row [barcodedata. labeldescription_field] = labledescritiop_txt.text.trim ();
Row [barcodedata. description_field] = description_txt.text.trim ();
Row [barcodedata. newdescription_field] = updatedesc_txt.text.trim ();
Row [barcodedata. lastmodify_field] = system. datetime. now;
Row. acceptchanges ();
I click the update button to update the data order by tracking
1-2-3-4
Here is a logic error:
That is, step 1 should not be executed.
According to my ideas,
The data is not updated because the data is rebound in step 3.
However, the result is the opposite: the data is updated.
The normal logic should be
1-2-4
Although I don't know how Microsoft handles it, I have rewritten two steps according to the correct logic.
Case actiontype. updatedbarcodeitem:
Setlabletotext ();
Code_txt.editenable = false;
Action_pal.visible = true;
Add_btn.visible = false;
If (! Ispostback)
This. bindlist ();
Break;
Indicates that data is rebound when page load is not performed during post.