gridview中单击那个选择按钮取到那行的ID值?
<asp:GridViewID="GridView1"runat="server"AllowPaging="True"AutoGenerateColumns="False...
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px"
CellPadding="4" DataKeyNames="id" GridLines="Horizontal" Height="100%" PageSize="5" OnPageIndexChanging="GridView1_PageIndexChanging">
<RowStyle BackColor="White" ForeColor="#333333" />
<Columns>
<asp:CommandField ButtonType="Button" HeaderText="选择" ShowSelectButton="True">
<ItemStyle HorizontalAlign="Center" Width="80px" />
</asp:CommandField>
<asp:BoundField DataField="id" HeaderText="用户ID">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="adminname" HeaderText="登录帐号">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="adminpass" HeaderText="登录密码">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#333333" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
</asp:GridView>
我点了选择后 然后点下面的修改 要跳到另个网页 怎么取到选中这行的ID值呢? 展开
BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px"
CellPadding="4" DataKeyNames="id" GridLines="Horizontal" Height="100%" PageSize="5" OnPageIndexChanging="GridView1_PageIndexChanging">
<RowStyle BackColor="White" ForeColor="#333333" />
<Columns>
<asp:CommandField ButtonType="Button" HeaderText="选择" ShowSelectButton="True">
<ItemStyle HorizontalAlign="Center" Width="80px" />
</asp:CommandField>
<asp:BoundField DataField="id" HeaderText="用户ID">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="adminname" HeaderText="登录帐号">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="adminpass" HeaderText="登录密码">
<ItemStyle HorizontalAlign="Center" Width="100px" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#333333" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
</asp:GridView>
我点了选择后 然后点下面的修改 要跳到另个网页 怎么取到选中这行的ID值呢? 展开
1个回答
展开全部
添加GridView的SelectedIndexChanging事件处理函数
void GridView1_SelectedIndexChanging(Object sender, GridViewSelectEventArgs e)
{
GridViewRow row = CustomersGridView.Rows[e.NewSelectedIndex];
string strUserId=row.Cells[1].Text;
string strUserName=row.Cells[2].Text;
string strUserPassword=row.Cells[3].Text;
}
void GridView1_SelectedIndexChanging(Object sender, GridViewSelectEventArgs e)
{
GridViewRow row = CustomersGridView.Rows[e.NewSelectedIndex];
string strUserId=row.Cells[1].Text;
string strUserName=row.Cells[2].Text;
string strUserPassword=row.Cells[3].Text;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询