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

推荐订阅源

Engineering at Meta
Engineering at Meta
博客园_首页
H
Help Net Security
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
B
Blog
I
InfoQ
SecWiki News
SecWiki News
T
Tailwind CSS Blog
Spread Privacy
Spread Privacy
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
P
Palo Alto Networks Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
M
MIT News - Artificial intelligence
S
Schneier on Security
T
Threat Research - Cisco Blogs
F
Fortinet All Blogs
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The Cloudflare Blog
Recent Announcements
Recent Announcements
Security Latest
Security Latest
G
GRAHAM CLULEY
IT之家
IT之家
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
腾讯CDC
Google DeepMind News
Google DeepMind News
V
V2EX
S
Securelist
TaoSecurity Blog
TaoSecurity Blog
B
Blog RSS Feed
S
SegmentFault 最新的问题
博客园 - 叶小钗
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Project Zero
Project Zero
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure

博客园 - 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"的值.