dropdownlist项目以在gridview中突出显示 [英] dropdownlist item to get highlighted in gridview
本文介绍了dropdownlist项目以在gridview中突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我需要帮助.
我有一个下拉列表,其中包含来自"Emp_Tab"表中具有
的名称
名称"列.
我也有一个Gridview,它的数据源来自"Emp_Tab".
每当我从ddlist中选择任何名称时,我都希望具有该名称的特定行突出显示.
我无法弄清楚.
有任何建议吗?
Hello,
I need help with this.
I have a dropdownlist which contains names from ''Emp_Tab'' table having
''Name'' column.
I also have a gridview having datasource from ''Emp_Tab''.
Whenever I select any name from ddlist, I want the particular row with that name to get highlighted.
I am not able to figure it out.
Any suggestions?
推荐答案
您好,
如果您具有网格视图.
Hello ,
if you have the grid view .
<asp:GridView ID="gvEmployees" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" DataSourceID="objGroups" OnRowCommand="gdvGroups_RowCommand" Width="60%" meta:resourcekey="gdvGroupsResource1">
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#E3EAEB" />
<Columns>
<asp:BoundField HeaderText="Employee ID" />
<asp:BoundField HeaderText="Employee Name" />
</Columns>
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
您可以在ddl选择的索引更改功能中编写此代码.
You write this code in ddl selected index changed function.
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
gvEmployees.DataBind();//return rows colors to normal
foreach (GridViewRow row in gvEmployees.Rows)
{
if (row.Cells[1].Text == ddl.SelectedItem.Text)
{
row.BackColor = System.Drawing.Color.Blue;
}
}
}
就这样!
问候
Abraheem Abulubbad
.NET Developer
That''s it!
Regards
Abraheem Abulubbad
.NET Developer
这篇关于dropdownlist项目以在gridview中突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文