asp.net模板列 Command 命令 应用SelectedRowStyle
2009-09-17 11:26
405 查看
在gridview中
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<asp:TemplateField HeaderText="Remove">
<ItemStyle Font-Names="Arial" Font-Size="8pt"
HorizontalAlign="Center"/>
<HeaderStyle HorizontalAlign="Center" Font-Bold="True" Font-
Names="Arial" Font-Size="8pt" />
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"
OnCommand="LinkButton1_Command">Remove</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
</asp:GridView>
protected void LinkButton1_Command(object sender, CommandEventArgs e)
{
LinkButton lb = (LinkButton)sender;
DataControlFieldCell dcf = (DataControlFieldCell)lb.Parent;
GridViewRow gvr = (GridViewRow)dcf.Parent;
GridView1.SelectedIndex = gvr.RowIndex; //如果点击当前行的Remove此行会变成
SelectedRowStyle的相应颜色
string id = this.GridView1.Rows[GridView1.SelectedIndex].Cells[1].Text;
..........
}
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<asp:TemplateField HeaderText="Remove">
<ItemStyle Font-Names="Arial" Font-Size="8pt"
HorizontalAlign="Center"/>
<HeaderStyle HorizontalAlign="Center" Font-Bold="True" Font-
Names="Arial" Font-Size="8pt" />
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"
OnCommand="LinkButton1_Command">Remove</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
</asp:GridView>
protected void LinkButton1_Command(object sender, CommandEventArgs e)
{
LinkButton lb = (LinkButton)sender;
DataControlFieldCell dcf = (DataControlFieldCell)lb.Parent;
GridViewRow gvr = (GridViewRow)dcf.Parent;
GridView1.SelectedIndex = gvr.RowIndex; //如果点击当前行的Remove此行会变成
SelectedRowStyle的相应颜色
string id = this.GridView1.Rows[GridView1.SelectedIndex].Cells[1].Text;
..........
}
相关文章推荐
- dotnet new 命令使用模板生成Angular应用
- asp.net控件开发基础(6) -- 关于style的应用
- ASP.NET MVC 5– 使用Wijmo MVC 5模板1分钟创建应用
- ASP.NET MVC 5– 使用Wijmo MVC 5模板1分钟创建应用
- SharePoint 2010中的客户端AJAX应用——ASP.NET AJAX模板
- ASP.NET MVC 5– 使用Wijmo MVC 5模板1分钟创建应用
- ASP.NET MVC 5– 使用Wijmo MVC 5模板1分钟创建应用
- 在ASP.NET WEB控件中应用样式(Style)[转]
- [转]ASP.NET MVC 5– 使用Wijmo MVC 5模板1分钟创建应用
- dotnet new 命令使用模板生成Angular应用
- ASP.NET MVC 5– 使用Wijmo MVC 5模板1分钟创建应用
- ASP.NET Core Web App应用第三方Bootstrap模板的方法教程
- ASP.ASP.NET应用模板采用
- 在ASP.NET WEB控件中应用样式(Style)
- ASP.NET 2.0 GridView的RowCommand…
- 在ASP.NET WEB控件中应用样式(Style)
- ASP.NET MVC 5– 使用Wijmo MVC 5模板1分钟创建应用
- 在ASP.NET WEB控件中应用样式(Style)
- How to get the Values of Selected Row from a Gridview using ASP.NET
- 关于Asp.net应用中cookie的问题处理