CRM [controls and data table shadows]

Source: Internet
Author: User

In ASP. in net programming, it is often necessary to draw a form, pile up our controls, and then repeatedly write some new, edit, and update repetitive work. in fact, most of our work is the same, so we asked: is there a way to customize the interface on the client as long as [edit the aspx file, or edit the resource file] upload the file and then implement the functions we want. The answer is yes.
According to our habits, when editing a database, we need to obtain the value of the control that can be mapped to the data table field. Certainly, the control corresponds to the data table field. both data storage and display are required.

Question 1: how to map?
1. To map data fields to the Control ID, the common method is to work hard on the Control ID. when naming the Control ID, there is a field shadow. You can find the control through the data table field, form a ing, or use the resource file to define a ing relationship to directly obtain the relationship between data table words and controls.
For example, when the field name of a data table is ID, name, or title, the control can be named f_id, f_name, and f_title.
2. It is defined by the XML resource file.
For example: Name Table Name field name, ctrlid indicates the Control ID
<Mapper tablename = "xs_self_file" cname = "File Management">
<Field name = "ID" type = "C" cname = "single" ctrlid = "txt_fid" ctrltype = "TXT" keyword = "yes" value = "seq_self_file.nextval"/>
<Field name = "title" type = "C" cname = "file title" ctrlid = "txt_title" ctrltype = "TXT" keyword = "no"/>
<Field name = "name" type = "C" cname = "file name" ctrlid = "txt_filename" ctrltype = "TXT" keyword = "no"/>
<Field name = "path" type = "C" cname = "file path" ctrlid = "txt_filepath" ctrltype = "TXT" keyword = "no"/>
<Field name = "no" type = "C" cname = "File No." ctrlid = "txt_fileno" ctrltype = "TXT" keyword = "no"/>
<Field name = "Source" type = "C" cname = "file source" ctrlid = "txt_filesource" ctrltype = "TXT" keyword = "no"/>
<Field name = "type" type = "C" cname = "file type" ctrlid = "dll_type" ctrltype = "DLL" keyword = "no"/>
<Field name = "stop" type = "C" cname = "Disable" ctrlid = "dll_stop" ctrltype = "DLL" keyword = "no"/>
<Field name = "content" type = "C" cname = "file description" ctrlid = "txt_content" ctrltype = "TXT" keyword = "no"/>
<Field name = "addby" type = "C" cname = "Operation Time" ctrlid = "txt_addby" ctrltype = "TXT" keyword = "no"/>
<Field name = "addat" type = "C" cname = "operator" ctrlid = "txt_addat" ctrltype = "TXT" keyword = "no"/>
</Mapper>

Question 2: How do I obtain controls?
1. If the Control ID is used for shadow, you can traverse the sub-control of the [recursive] control container (such as page and htmlform) to see what container our control is under. search related input controls and then corresponding data table fields.
/// <Summary>
/// Obtain the table field control. In a custom form, the control name is F _ field name.
/// A m_tablename control must be set to store the table name.
/// </Summary>
Public hashtable getctrllist ()
{
Hashtable m_ht = new hashtable ();
Foreach (control m_ctrl in this. Page. Controls)
{
Foreach (control m_tb in m_ctrl.controls)
{
// If you have a word control that is not a custom control, search for the lower-level control!
If (m_tb.hascontrols ())&&(! (M_tb is usercontrol )))
{
Getctrllist ();
}
Else
{
If (m_tb.id = NULL)
{
Continue;
}

If (m_tb.gettype (). tostring () = "system. Web. UI. literalcontrol") // if it is a space
{
Continue;
}

If (! M_tb.id.startswith ("F _") // if it is a field
{
Continue;
}
M_ht.add (m_tb.id.replace ("F _", ""). tolower (), m_tb );
} // Endof [If (Tb. hascontrols ())&&(! (TB is usercontrol)]
} // End of loop for {TB}
} // End of loop for {CTRL}
Return m_ht;
} // End of Function

2. If it is XML, we can use the control ID to find the control and the findcontrol () of page to get the control and value.

Question 3: How to form an SQL statement?
You can split the SQL rules based on the two projection relationships to study the insert, update, delete, and select statements.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.