惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
G
Google Developers Blog
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
aimingoo的专栏
aimingoo的专栏
N
News and Events Feed by Topic
L
LINUX DO - 最新话题
V
Vulnerabilities – Threatpost
H
Hacker News: Front Page
T
Tor Project blog
P
Proofpoint News Feed
P
Privacy International News Feed
Recorded Future
Recorded Future
F
Fortinet All Blogs
量子位
博客园 - 聂微东
月光博客
月光博客
博客园 - Franky
SecWiki News
SecWiki News
G
GRAHAM CLULEY
腾讯CDC
Know Your Adversary
Know Your Adversary
宝玉的分享
宝玉的分享
The Cloudflare Blog
美团技术团队
小众软件
小众软件
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Threatpost
爱范儿
爱范儿
A
Arctic Wolf
博客园 - 叶小钗
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Project Zero
Project Zero
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园 - 三生石上(FineUI控件)
PCI Perspectives
PCI Perspectives
Latest news
Latest news
V
V2EX
罗磊的独立博客
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
S
Security Affairs
S
SegmentFault 最新的问题

博客园 - Ellipse

Design by Contract what's interface Provider, Manager, Helper - Ellipse Build your own CAB #13 - Embedded Controllers with a Dash of DSL Layer supertype for MVP - Ellipse Build your own CAB#12 - Rein in runaway events with the "Latch " Build your own CAB#11 - Event Aggregator Build your own CAB Part #9 - Domain Centric Validation with the Notification Pattern Build your own CAB Part#8 - Assigning Responsibilities in a MVP pattern Build your own CAB Par#7 - what's the Model? Having a break Build your own CAB Part #6 - View to Presenter Communication Build your own CAB Part #4 - The Passive View Build your own CAB Part #3 - The Supervising Controller Pattern Build your own CAB Part #1 - The Preamble(Jeremy D. Miller) Build your own CAB Part #2 - The Humble Dialog Box -- Jeremy D. Miller Reading Build your own CAB (1) -- Jeremy D. Miller ActionList Webpage redirection
Gridview 的RowCommand
Ellipse · 2007-09-11 · via 博客园 - Ellipse

[http://www.cnblogs.com/cnaspnet/archive/2007/05/04/669410.html]
也是在这次项目开发遇到的问题,本来放在一起的,后来发现太长了,所有就分开来写.
不过都是一些非常简单的问题,怕忘记,在这里作一个记录.

GridView模版列中Button取值问题:

 1  <asp:GridView ID="GridView1" runat="server" DataKeyNames="id" AutoGenerateColumns="
               False
" ShowHeader="False" Width="100%" OnRowDataBound="
                GridView1_RowDataBound" OnRowCommand="GridView1_RowCommand">
 2             <Columns>
 3                 <asp:BoundField DataField="dept" >
 4                     <ItemStyle Height="20px" Width="10%" HorizontalAlign="Center" />
 5                 </asp:BoundField>
 6                 <asp:BoundField DataField="deptnm" >
 7                     <ItemStyle Width="15%" />
 8                 </asp:BoundField>
 9                 <asp:TemplateField>
10                     <ItemTemplate>
11                         意见:<asp:TextBox CssClass="inputLine" ID="txtNotion" runat="server" Width="300px"></asp:TextBox>
12                     </ItemTemplate>
13                     <ItemStyle Width="40%" />
14                 </asp:TemplateField>
15                 <asp:TemplateField>
16                     <ItemTemplate>
17                         <asp:HiddenField ID="hditem" runat="server" Value='<%# Eval("item") %>' />
18                         <asp:RadioButtonList ID="rblidea" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
19                             <asp:ListItem Value="1">同意</asp:ListItem>
20                             <asp:ListItem Value="0">不同意</asp:ListItem>
21                         </asp:RadioButtonList>
22                     </ItemTemplate>
23                     <ItemStyle HorizontalAlign="Center" Width="20%" />
24                 </asp:TemplateField>
25                 <asp:TemplateField>
26                     <ItemTemplate>
27                         <asp:Button ID="btnSubVise" CommandName="vise" CommandArgument='<%# Eval("id") %>'
                                 runat="server" Text="提 交" CssClass="Sub_button2" />&nbsp;
28                         <input id="ReSubVise" type="reset" value="重 置" class="Sub_button2" runat="server" />
29                     </ItemTemplate>
30                     <ItemStyle HorizontalAlign="Center" Width="15%" />
31                 </asp:TemplateField>
32             </Columns>
33         </asp:GridView>

点击"提交"这个按钮,想取得"意见"这个TextBox的值.

 1 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 2         {
 3             GridViewRow row = ((Control)e.CommandSource).BindingContainer as GridViewRow;
 4             int index = row.RowIndex;
 5 
 6             string strid = e.CommandArgument.ToString();
 7 
 8             if (e.CommandName == "vise")
 9             {
10                 string strid = GridView1.DataKeys[index].Value.ToString();
11                 TextBox txtNotion = (TextBox)row.FindControl("txtNotion");
12 
13                 Response.Write(txtNotion.Text.ToString());
14             }
15         }

e.CommandArgument是取CommandArgument='<%# Eval("id") %>'的值.index是取GridView中DataKeyNames="id"的值.