(elementary). NET control GridView binding Data

Source: Internet
Author: User
Tags oracleconnection

Foreground GridView property setting

<td>
<asp:gridview id= "GridView" runat= "Server" autogeneratecolumns= "false" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:checkbox runat= "Server"/>
</ItemTemplate>
<HeaderTemplate>
<asp:checkbox runat= "Server"/>
</HeaderTemplate>
</asp:TemplateField>
<asp:boundfield datafield= "Cusername" headertext= "name"/>
<asp:boundfield datafield= "Cusercode" headertext= "ID"/>
<asp:boundfield datafield= "Cpwddate" headertext= "SEX"/>
<asp:boundfield datafield= "Ccreateusername" headertext= "Memo"/>
<asp:TemplateField>
<ItemTemplate>
<a href= "Javascript:mytest (' <% #Eval (" Cusercode ")! =" "? Eval ("Cusercode"). ToString (): ""%> ') "> Modify </a>
</ItemTemplate>
<HeaderTemplate>
Operation
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<a href= "Javascript:mytest (' <% #Eval (" Cusercode ")! =" "? Eval ("Cusercode"). ToString (): ""%> ') "> View </a>
</ItemTemplate>
<HeaderTemplate>
View
</HeaderTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Background Data binding:

Because you are connecting to an Oracle database, you need to import a namespace

Using System.Data;
Using System.Data.OracleClient;

String Conn = "server=mrm;uid=bcc;pwd=bcc.51";
OracleConnection cconn = new OracleConnection (Conn);
OracleDataAdapter Da = new OracleDataAdapter ("SELECT * from T_user", cconn);
DataSet ds = new DataSet ();
Da.fill (DS);
This. Gridview.datasource = ds. Tables[0]. DefaultView;
This. Gridview.databind ();

Displayed effect (coarser):

(elementary). NET control GridView binding Data

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.