asp.net - Grid view and class library -


i using class library , asp.net form. in class library created class retrieving database value based on specific fileid.i have no idea how connect class gridview.tried using gridview.databind(obj).not working. appreciate thanks

in asp.net form

       dim retobj new mailbox        retobj.mailboxname = mailb.text      insmairet = new clsmailboxcollect     insmairet.retrievemail(retobj)      gridview1.databind(retobj) 

the simplest way use sqldatasource , gridview.

you can use follows:

  <asp:sqldatasource       id="sqldatasource1"       runat="server"       datasourcemode="datareader"       connectionstring="<%$ connectionstrings:mynorthwind%>"       selectcommand="select firstname, lastname, title employees">   </asp:sqldatasource>    <asp:gridview       id="gridview1"       runat="server"       datasourceid="sqldatasource1">   </asp:gridview> 

click here details.

edit if use custom implementation access data can use objectdatasource.

    <asp:gridview       id="gridview1"       runat="server"       datasourceid="objectdatasource1" />      <asp:objectdatasource       id="objectdatasource1"       runat="server"       selectmethod="getallemployees"       typename="mydatabaselogic" /> 

in case mydatabaselogic be:

public class mydatabaselogic {     // returns collection of northwindemployee objects.      public static icollection getallemployees () {         return new arraylist();     } } 

click here details.

sorry c#, can convert vb.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -