Asp. NET to display the data in the TextBox through the GridView selection button

Source: Internet
Author: User

HTML code:

<asp:gridview id= "GridView1" runat= "Server" datakeynames= "CKDH" height= "183px" style= "left:0px";
           position:relative; Top: -18px; Font-size:small; "
            Width= "864px" allowpaging= "true" allowsorting= "true" autogeneratecolumns= "False" datasourceid= "SqlDataSource1" autogenerateselectbutton= "True" cellpadding= "4" forecolor= "#333333" gridlines= "None" onselectedindexchanging= " Gridview1_selectedindexchanging "emptydatatext=" not entered "> <pagerstyle horizontalalign=" Right "BackColor=" #FFC C66 "forecolor=" #333333 "/> <pagersettings mode=" Nextpreviousfirstlast "firstpagetext=" first page "Previouspaget ext= "Previous page" nextpagetext= "Next" lastpagetext= "last Page"/> <Columns> <asp:boundfield Data Field= "CKDH" headertext= "out of the library number" sortexpression= "CKDH"/> <asp:boundfield "datafield=" ckkb = "Out of the Library" sortexpression= "ckkb"/> <asp:boundfield datafield= "ypqx" headertext= "Drug whereabouts" Sortexpression= "Ypqx"/> <asp:boundfield datafield= "YPBH" headertext= "drug number" sortexpression= "YPBH"/> <asp:boundfield datafield= "YPMC" headertext= "Drug name" sortexpression= "YPMC"/> <asp: BoundField datafield= "GG" headertext= "Pharmaceutical Specifications" sortexpression= "GG"/> <asp:boundfield "DW" headertext= "Drug unit" sortexpression= "DW"/> <asp:boundfield datafield= "sj" headertext= "out of the library price" Sortexpre
           ssion= "SJ"/> <asp:boundfield datafield= "SL" headertext= "number of out of stock" sortexpression= "SL"/>
           </Columns> <selectedrowstyle forecolor= "Navy" backcolor= "#FFCC66" font-bold= "True"/> <rowstyle forecolor= "#333333" backcolor= "#FFFBD6"/> <footerstyle backcolor= "#990000" font-bold= "Tru
           E "forecolor="/>  

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/aspx/

C # Background code:

protected void Gridview1_selectedindexchanging (object sender, GridViewSelectEventArgs a) {TextBox1.Text = Gr Idview1.rows[a.newselectedindex]. CELLS[1].
        Text.tostring (); TextBox2.Text = Gridview1.rows[a.newselectedindex]. CELLS[2].
        Text.tostring (); TextBox3.Text = Gridview1.rows[a.newselectedindex]. CELLS[3].
        Text.tostring (); Textbox4.text = Gridview1.rows[a.newselectedindex]. CELLS[4].
        Text.tostring (); Textbox5.text = Gridview1.rows[a.newselectedindex]. CELLS[5].
        Text.tostring (); Textbox6.text = Gridview1.rows[a.newselectedindex]. CELLS[6].
        Text.tostring (); Textbox7.text = Gridview1.rows[a.newselectedindex]. CELLS[7].
        Text.tostring (); Textbox8.text = Gridview1.rows[a.newselectedindex]. CELLS[8].
        Text.tostring (); Textbox9.text = Gridview1.rows[a.newselectedindex]. CELLS[9].
        Text.tostring ();
        session["Shuliang"] = Convert.ToInt32 (Textbox9.text); Textbox10.text = Gridview1.rows[e.newselectedindex]. CELLS[10]. Text.
        ToString (); Textbox11.text = Gridview1.rows[e.newselectedindex]. CELLS[11].
        Text.tostring (); TextBox1.Text = Gridview1.rows[e.newselectedindex]. CELLS[1].
        Text.tostring ();
    
        Response.Write ("

  
  

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.