Use the onselectedindexchanged event of dropdownlist in the gridview

Source: Internet
Author: User

 

Today, we encountered the onselectedindexchanged event using dropdownlist in the gridview. In this summary, it is convenient for Boyou to refer.

Front-endCode:

<Asp: templatefield headertext = "  Score  " Itemstyle-horizontalalign = "  Center  " > <Itemtemplate> <asp: dropdownlist id = "  Gradelist  " Runat = " Server  " Width = "  100px  " Onselectedindexchanged = "  Dd_selectedindexchanged  "  Autopostback = "  True  " > <Asp: listitem> </ASP: listitem> <asp: listitem> 0 </ASP: listitem> <asp: listitem> 10 </ASP: listitem> <asp: listitem> 20 </ASP: listitem> <asp: listitem> 30 </ASP: listitem> <asp: listitem> 40 </ASP: listitem> <asp: listitem> 50 </ASP: listitem> <asp: listitem> 60 </ASP: listitem> <asp: listitem>70 </ASP: listitem> <asp: listitem> 80 </ASP: listitem> <asp: listitem> 90 </ASP: listitem> <asp: listitem> 100 </ASP: listitem> </ASP: dropdownlist> </itemtemplate> </ASP: templatefield>

Background onselectedindexchanged event:

 ///   <Summary>      ///  Rating  ///  </Summary>      ///   <Param name = "sender"> </param>      ///   <Param name = "E"> </param>      Protected   Void Dd_selectedindexchanged ( Object  Sender, eventargs e) {gridviewrow gvr = (Gridviewrow) (Control) sender). Parent. parent; dropdownlist DDL = (Dropdownlist) sender; //  Obtain the dropdownlist1 control in gridview1. //  You can also write it like this.  //  Gridviewrow ROW = (gridviewrow) DDL. Parent. parent;  //  Gridviewrow row1 = (gridviewrow) DDL. namingcontainer;  //  Use the DDL control to find the row  //  Int AA = convert. toint32 (row1.rowindex. tostring ());  //  Obtain rowindex of a row Querybuilder QB = New Querybuilder (); QB. addfilter (  "  Mis_gradeinfo.sf_userid  " , Webcommon. SQL _equal, gvr. cells [ 0  ]. Text); QB. addfilter (  "  Mis_gradeinfo.df_week  " , Webcommon. SQL _equal, gvr. cells [ 2  ]. Text); ilist <Mis_gradeinfomodel> mis_gradeinfomodel = Bll. getmis_gradeinfomodelbycondition (QB ); If (Mis_gradeinfomodel.count> 0  ) {Model = Mis_gradeinfomodel [ 0  ]; Model. df_userid = Usernum. value; model. df_username = Username. Text; model. gradenum = DDL. selectedvalue. tostring (); //  Obtain the selected value Model. df_flag = 1 ; //  Indicates the score ID. Model. df_date = Datetime. Now. to1_datestring (); Model. up_df_date = Datetime. Now. tow.datestring (); BLL. update_mis_gradeinfo (model );}} 

 

 

 

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.