Implement the set of gridview and image display in the gridview

Source: Internet
Author: User
Quick review
Knowledge point:
1. The gridview is bound to the objectdatasource. When configuring the data source, the parameter is an object, for example, modifyadmin (Admin admin)
2. Set the gridview and add the image to the image (see the 2nd points marked in red below)

1. Description of the temp page: (pass an object parameter)
1. The gridview and detailsview are combined to implement query, deletion, addition, and modification (similar to those with parameters, which is not mentioned here)
Specific look: http://www.cnblogs.com/jason-xiao/archive/2009/02/20/1394656.html
The difference is that when you configure the data source, select the object as the parameter, andCodeAlso different:

Code in updating
This is the specific parameter
Dropdownlist ddl_role = detailsview1.findcontrol ("dropdownlist2") as dropdownlist;
E. inputparameters ["roleid"] = ddl_role.selectedvalue;
This is the object
Dropdownlist ddlrole = detailsview_admin.findcontrol ("dropdownlist_role") as dropdownlist;
Admin admin = E. inputparameters ["admin"] as admin;
Admin. Role = rolemanager. getrolebyroleid (convert. toint32 (ddlrole. selectedvalue ));

2. Use text boxes to add, delete, and modify code and interfaces

Text Box to update the gridview code
Protected   Void Btnadd_click ( Object Sender, eventargs E)
{
Admin =   New Admin ();
Admin. Username = Txtusername. text;
Admin. Password = Txtpassword. text;
Admin. Role = Rolemanager. getrolebyroleid (convert. toint32 (dropdownlist_role.selectedvalue ));
Adminmanager. addadmin (Admin );
Gridview_admin.databind ();
}

 

* 2. description of the gridview_include.aspx page: (implement the set of gridview and image display in the gridview)
1. add a new template column: After the gridview and role tables are bound (set datakeynames to roleid),
click the upper right triangle of the gridview (click Add new column and select the bottom templatefield ).
2. edit the template column and drag a gridview (gridview2 is called, and gridview2 is bound to Admin.
the query method is getadminbyroleid (int32 roleid), and select none from the parameter source, defaultview is assigned to 1)
3. in the databinding event of the gridview2 data source, write a code (to assign the roleid value to the parameter of the
getadminbyroleid (int32 roleid) method of gridview2)
(objectdatasource) sender ). selectparameters ["roleid"]. defaultvalue =
(gridviewrow) (objectdatasource) sender ). parent. parent )). cells [1]. text;

2.1 image, which is also a new template column. Drag an image into itemtemplate in the toolbox and bind the data to rolename. Format: regular -{}
Write in custom code such as: eval ("rolename", "images/role 02.16.gif") images/role 02.16.gif

3. Code: http://www.namipan.com/downfile/GridView_Included2009-2-22.rar/f4bb5d2f6bd114e26e902062d16c24782fa2d80ab36d0700

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.