返回首页

您好所有
我发展的电影院座位预订网站,我已经放置在ASP中的席位图像:GridView中使用的ImageButton模板(所有细胞),当时我需要我点击单元格的值,选择座位的ImageButton(单元)点击在GridView的ImageButton。

我收到的RowIndex但不ColIndex。

 <asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="False" 

                                                Width="755px" AllowPaging="True" 

                                                

                                                PageSize="26" ShowHeader="true" CellSpacing="1" 

                            onrowupdating="Gridview1_RowUpdating" 

                            onrowcommand="Gridview1_RowCommand">

                                                <rowstyle borderstyle="None" />

                                                

                                                <columns>

                                               

                                                

                   <asp:TemplateField >

                                                <itemtemplate>

         <asp:HyperLink ID="HyperLink1" Text='<%# Eval("SeatRow") %>' runat="server">

                                                </itemtemplate>

                                                <itemstyle borderstyle="None" />

                                                

                   

                   

                   <asp:TemplateField HeaderText ="1" >

                   

                                                <itemtemplate>

                                                

 <asp:ImageButton ID="ImageButton1"  CommandArgument='<%# Eval("C1") %>' CommandName="ib1" 

 Visible='<%# MyVisible(Eval("C1").ToString()) %>' runat="server" ImageUrl='<%# MyImg(Eval("C1").ToString()) %>' Text='<%# MyValue(Eval("C1").ToString()) %>' OnClick ="ImageButton1_Click"/>

                                                </itemtemplate>

                                                <itemstyle borderstyle="None" />

                   

                   

                   <asp:TemplateField HeaderText ="2">

                                                <itemtemplate>

 <asp:ImageButton ID="ImageButton2" runat="server" CommandArgument='<%# Eval("C2") %>' 

 CommandName="ib2" Visible='<%# MyVisible(Eval("C2").ToString()) %>' ImageUrl='<%# MyImg(Eval("C2").ToString()) %>' 

 OnClick="button_click" RowIndex='<%# Container.DisplayIndex %>'/>

                                                </itemtemplate>

                                                <itemstyle borderstyle="None" />

                                                

                   

                   <asp:TemplateField HeaderText ="3">

                                                <itemtemplate>

<asp:ImageButton ID="ImageButton3" runat="server" CommandArgument='<%# Eval("C3") %>'

 CommandName="ib3" Visible='<%# MyVisible(Eval("C3").ToString()) %>' ImageUrl='<%# MyImg(Eval("C3").ToString()) %>'/>

                                                </itemtemplate>

                                                <itemstyle borderstyle="None" />

                                                

 



 

 </columns>

                                                <footerstyle borderstyle="None" />

                                                <SelectedRowStyle BorderStyle="None" />

                                                <editrowstyle borderstyle="None" />

                                                <alternatingrowstyle borderstyle="None" />

defaust.aspx.cs
{C}

回答

评论会员:游客 时间:2012/02/04
advancedansh:你可以使用这个..codeprelang="c#"spanclass="code-keyword"private/spanspanclass="code-keyword"void/spanGridView1_Cell_Click(spanclass="code-keyword"object/spansender,GridViewCellEventArgse){spanclass="code-keyword"int/spancellindex=e.CellIndex;spanclass="code-keyword"int/spanrowindex=e.rowindex;spanclass="code-keyword"var/spanvalue=GridView1.Rows[rowindex].Cells[cellindex].value;}/pre/code的:AbhijitANA
{C3的}
例如,你有像上面的DataGrid
试着在你的cs文件

{的C4}
评论会员:游客 时间:2012/02/04
hilmisu:尝试使用,GridViewRowCommand事件,CommandName和CommandArgument。在这里我给的答案类似的类型,imgsrc=]
Abhijit ANA
评论会员:游客 时间:2012/02/04
{C5的}执行这样的代码