gridview怎么获取当前行某列的值 详细如下:
我想获取里面“删除”按钮事件当前行第0列的值。麻烦各位大虾帮下忙。谢谢了!部分代码如下:<asp:GridViewID="GridView2"runat="server"...
我想获取里面“删除”按钮事件当前行第0列的值。
麻烦各位大虾帮下忙。谢谢了!
部分代码如下:
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" BackColor="White"
BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4" Width="666px" OnRowDeleting="GridView2_RowDeleting" >
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<Columns>
<asp:BoundField DataField="CourseCode" HeaderText="课程号" SortExpression="CourseCode" />
<asp:BoundField DataField="CourseName" HeaderText="课程名" SortExpression="CourseName" />
<asp:BoundField DataField="CreditHour" HeaderText="学分" SortExpression="CreditHour" />
<asp:BoundField DataField="TeacherName" HeaderText="任课老师" SortExpression="CourseTeacher" />
<asp:BoundField DataField="CourseTime" HeaderText="上课时间" SortExpression="CourseTime" />
<asp:BoundField DataField="CoursePlace" HeaderText="上课地点" SortExpression="CoursePlace" />
<asp:TemplateField HeaderText="退选">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick="return confirm('确认要删除吗?');" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
</asp:GridView> 展开
麻烦各位大虾帮下忙。谢谢了!
部分代码如下:
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" BackColor="White"
BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4" Width="666px" OnRowDeleting="GridView2_RowDeleting" >
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<Columns>
<asp:BoundField DataField="CourseCode" HeaderText="课程号" SortExpression="CourseCode" />
<asp:BoundField DataField="CourseName" HeaderText="课程名" SortExpression="CourseName" />
<asp:BoundField DataField="CreditHour" HeaderText="学分" SortExpression="CreditHour" />
<asp:BoundField DataField="TeacherName" HeaderText="任课老师" SortExpression="CourseTeacher" />
<asp:BoundField DataField="CourseTime" HeaderText="上课时间" SortExpression="CourseTime" />
<asp:BoundField DataField="CoursePlace" HeaderText="上课地点" SortExpression="CoursePlace" />
<asp:TemplateField HeaderText="退选">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick="return confirm('确认要删除吗?');" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="White" ForeColor="#330099" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
</asp:GridView> 展开
1个回答
展开全部
把值放给Button 的CommandArgument属性
<asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="DeleteCourse" CommandArgument='<%# Bind("CourseCode") %>'
Text="删除" OnClientClick="return confirm('确认要删除吗?');" />
取值
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DeleteCourse")
{
string CourseCode= e.CommandArgument.ToString()
}
}
<asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="DeleteCourse" CommandArgument='<%# Bind("CourseCode") %>'
Text="删除" OnClientClick="return confirm('确认要删除吗?');" />
取值
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DeleteCourse")
{
string CourseCode= e.CommandArgument.ToString()
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询