<%@ page enablesessionstate="false" %>
<script language="c#" runat="server"> public dataset ds; ... void page_load(object sender, eventargs e) { // ...set up a connection and command here... if (!page.ispostback) { string query = "select * from authors where firstname like '%justin%'"; mycommand.fill(ds, "authors"); mydatagrid.databind(); } } void button_click(object sender, eventargs e) { string query = "select * from authors where firstname like '%brad%'"; mycommand.fill(ds, "authors"); mydatagrid.databind(); }</script><form runat="server"> <asp:datagrid datasource='<%# ds.defaultview %>' runat="server"/><br> <asp:button onclick="button_click" runat="server"/></form>
<script language="vb" runat="server"> public ds as dataset ... sub page_load(sender as object, e as eventargs) ' ...set up a connection and command here... if not (page.ispostback) dim query as string = "select * from authors where firstname like '%justin%'" mycommand.fill(ds, "authors") mydatagrid.databind() end if end sub sub button_click(sender as object, e as eventargs) dim query as string = "select * from authors where firstname like '%brad%'" mycommand.fill(ds, "authors") mydatagrid.databind() end sub</script><form runat="server"> <asp:datagrid datasource='<%# ds.tables["authors"].defaultview %>' runat="server"/><br> <asp:button onclick="button_click" runat="server"/></form>
<script language="jscript" runat="server"> public var ds:dataset; ... function page_load(sender:object, e:eventargs) : void { // ...set up a connection and command here... if (!page.ispostback) { var query:string = "select * from authors where firstname like '%justin%'"; mycommand.fill(ds, "authors"); mydatagrid.databind(); } } function button_click(sender:object, e:eventargs) : void { var query:string = "select * from authors where firstname like '%brad%'"; mycommand.fill(ds, "authors"); mydatagrid.databind(); }</script><form runat="server"> <asp:datagrid datasource='<%# ds.defaultview %>' runat="server"/><br> <asp:button onclick="button_click" runat="server"/></form>c# vb jscript
<script language="c#" runat="server"> public string imagepath; void page_load(object sender, eventargs e) { //...retrieve data for imagepath here... databind(); }</script><%-- the span and img server controls are unecessary...--%>the path to the image is: <span innerhtml='<%# imagepath %>' runat="server"/><br><img src='<%# imagepath %>' runat="server"/><br><br><%-- use databinding to substitute literals instead...--%>the path to the image is: <%# imagepath %><br><img src='<%# imagepath %>' /><br><br><%-- or a simple rendering expression...--%>the path to the image is: <%= imagepath %><br><img src='<%= imagepath %>' />
<script language="vb" runat="server"> public imagepath as string sub page_load(sender as object, e as eventargs) '...retrieve data for imagepath here... databind() end sub</script><%--the span and img server controls are unecessary...--%>the path to the image is: <span innerhtml='<%# imagepath %>' runat="server"/><br><img src='<%# imagepath %>' runat="server"/><br><br><%-- use databinding to substitute literals instead...--%>the path to the image is: <%# imagepath %><br><img src='<%# imagepath %>' /><br><br><%-- or a simple rendering expression...--%>the path to the image is: <%= imagepath %><br><img src='<%= imagepath %>' />
<script language="jscript" runat="server"> public var imagepath:string; function page_load(sender:object, e:eventargs) : void { //...retrieve data for imagepath here... databind(); }</script><%-- the span and img server controls are unecessary...--%>the path to the image is: <span innerhtml='<%# imagepath %>' runat="server"/><br><img src='<%# imagepath %>' runat="server"/><br><br><%-- use databinding to substitute literals instead...--%>the path to the image is: <%# imagepath %><br><img src='<%# imagepath %>' /><br><br><%-- or a simple rendering expression...--%>the path to the image is: <%= imagepath %><br><img src='<%= imagepath %>' />c# vb jscript
<asp:datagrid maintainstate="false" datasource="..." runat="server"/>
<%@ page maintainstate="false" %>note that this attribute is also supported by the user control directive. to analyze the amount of view state used by the server controls on your page, enable tracing and look at the view state column of the control hierarchy table. for more information about the trace feature and how to enable it, see the application-level trace logging feature.
// using concatenation operators can sometimes produce// cleaner-looking code, but performance is not as good.string begin_query = "select upper(machinename) as machinename, " + "lower(machineowner) as machineowner, status, " + "starttime from net_stress where ";string end_query = " and starttime > '" + starttime + "' and starttime < '" + endtime + "'";string query = begin_query + getwhereclause("passed") + end_query;// consider replacing with stringbuilder instead:stringbuilder begin_query = new stringbuilder();begin_query.append("select upper(machinename) as machinename ");begin_query.append("lower(machineowner) as machineowner, status, ");begin_query.append("starttime from net_stress where ");stringbuilder end_query = new stringbuilder();end_query.append(" and starttime > '");end_query.append(starttime);end_query.append("' and starttime < '");end_query.append(endtime);end_query.append("'");string query = begin_query.append(getwhereclause("passed")).append(end_query).tostring();
' using concatenation operators can sometimes produce' cleaner-looking code, but performance is not as good.dim begin_query as string = "select upper(machinename) as machinename, " _ & "lower(machineowner) as machineowner, status, " _ & "starttime from net_stress where "dim end_query as string = " and starttime > '" & starttime & "' and starttime < '" & endtime & "'"dim query as string = begin_query & getwhereclause("passed") & end_query' consider replacing with stringbuilder instead:dim begin_query as new stringbuilderbegin_query.append("select upper(machinename) as machinename ")begin_query.append("lower(machineowner) as machineowner, status, ")begin_query.append("starttime from net_stress where ")dim end_query as new stringbuilderend_query.append(" and starttime > '")end_query.append(starttime)end_query.append("' and starttime < '")end_query.append(endtime)end_query.append("'")dim query as string = begin_query.append(getwhereclause("passed")).append(end_query).tostring()
// using concatenation operators can sometimes produce// cleaner-looking code, but performance is not as good.var begin_query:string = "select upper(machinename) as machinename, " + "lower(machineowner) as machineowner, status, " + "starttime from net_stress where ";var end_query:string = " and starttime > '" + starttime + "' and starttime < '" + endtime + "'";var query:string = begin_query + getwhereclause("passed") + end_query;// consider replacing with stringbuilder instead:var begin_query:stringbuilder = new stringbuilder();begin_query.append("select upper(machinename) as machinename ");begin_query.append("lower(machineowner) as machineowner, status, ");begin_query.append("starttime from net_stress where ");var end_query:stringbuilder = new stringbuilder();end_query.append(" and starttime > '");end_query.append(starttime);end_query.append("' and starttime < '");end_query.append(endtime);end_query.append("'");var query:string = begin_query.append(getwhereclause("passed")).append(end_query).tostring();c# vb jscript
最大的网站源码资源下载站,
新闻热点
疑难解答
图片精选