工作訴求是 利用查詢出來的bind資料,再利用於 C#後台進行操作
Asp.net :
在EVAL處動點手腳
1 |
<span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:Label</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="sys_dep_upLabel"</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">='<%# Eval("sys_dep_up") %>'</span> <span style="color: #0000ff">/></span> |
改成這樣,目的是呼叫後台進行操作
1 |
<span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff"><</span><span style="color: #800000">asp:Label</span> <span style="color: #ff0000">ID</span><span style="color: #0000ff">="sys_dep_upLabel"</span> <span style="color: #ff0000">runat</span><span style="color: #0000ff">="server"</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">='<%# getdepname_byid(Convert.ToInt32(Eval("sys_dep_up"))) %>'</span> <span style="color: #0000ff">/></span> |
C#:
建立一個事件, 並回傳結果
1 |
<span style="color: #606060" id="lnum1"> 1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> getdepname_byid(<span style="color: #0000ff">int</span> depid) |
1 |
<span style="color: #606060" id="lnum2"> 2:</span> { |
1 |
<span style="color: #606060" id="lnum3"> 3:</span> <span style="color: #008000">// ..... </span> |
1 |
<span style="color: #606060" id="lnum4"> 4:</span> <span style="color: #0000ff">return</span> <span style="color: #0000ff">string</span>; |
1 |
<span style="color: #606060" id="lnum5"> 5:</span> } |
(Visited 23 times, 1 visits today)