的onmouseover,属性的onmouseout没有在GridView的工作 [英] Onmouseover ,Onmouseout attributes were not working in gridview
问题描述
我已经尝试了所有这一切可能的方式突出显示GridView的一排,我能不能够才达到this.I试图直接CSS-类,JavaScript的。请注意我在哪里,我犯了一个错误。在此先感谢...
保护无效test_databound(对象发件人,GridViewRowEventArgs E)
{
如果(e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes [的onmouseover] =this.style.cursor ='手'; this.style.background ='#D1DDF1';;
e.Row.Attributes [的onmouseout] =this.style.background ='#EFF3FB';; //e.Row.Attributes[\"onmouseover] =JavaScript的:SetMouseOver(本);
//e.Row.Attributes[\"onmouseout] =JavaScript的:SetMouseOut(本); //e.Row.Attributes.Add(\"onmouseover,类名='highlighted1');
//e.Row.Attributes.Add(\"onmouseout,this.style.backgroundColor ='');
//e.Row.Attributes.Add(\"style,光标:指针;); //e.Row.Attributes.Add(\"onmouseover,this.style.backgroundColor ='#000000');
//e.Row.Attributes.Add(\"onmouseout,this.style.backgroundColor ='#000000');
//e.Row.Attributes.Add(\"style,光标:指针;);
//e.Row.Attributes.Add(\"onmouseover,this.originalstyle = this.style.backgroundColor; this.style.backgroundColor ='#000000');
//e.Row.Attributes.Add(\"onmouseout,this.style.backgroundColor = this.originalstyle);
//e.Row.Attributes.Add(\"style,光标:指针;);
}
//e.Row.Attributes.Add(\"onmousedown,IsMouseDown(此,真));
//e.Row.Attributes.Add(\"onmouseup,IsMouseDown(此,真));
//e.Row.Attributes.Add(\"onmouseover,HighlightRow(此,真));
//的foreach(GridViewRow在gvCatalogList.Rows成长)
// {
// e.Row.Attributes.Add(onmousedown事件,IsMouseDown(这));
// e.Row.Attributes.Add(onmouseup,IsMouseDown(这));
// grow.Attributes [的onmouseover] =亮点(这一点,真正的);;
// grow.Attributes [的onmouseout] =亮点(这一点,假);;
// Htt的presponse myHtt presponse =响应;
// HtmlTextWriter的myHtmlTextWriter =新的HtmlTextWriter(myHtt presponse.Output);
// grow.Attributes.AddAttributes(myHtmlTextWriter);
//}
}
这是我设计的网页
< ASP:GridView控件ID =gvCatalogList网格=无=服务器的AutoGenerateColumns =FALSE
每页=5AllowPaging =真OnPageIndexChanging =OnPageIndexChanging_gvCatalogList
OnRowDataBound =test_databound>
< FooterStyle的CssClass =分页,Flickr的/>
< PagerStyle的CssClass =分页,Flickr的HorizontalAlign =中心/>
<柱体和GT;
< ASP:的TemplateField的HeaderText =估计ID>
&所述; HeaderStyle裹=真宽度=10%/>
<&ItemTemplate中GT;
< DIV的风格=宽度:40像素;白色空间:正常>
< ASP:标签ID =LABEL1文本='<%#的eval(ProjectEstimationVersionID)%>' =服务器>< / ASP:标签>
< ASP:HiddenField ID =hiddenEstimationID=服务器值='<%#的eval(ProjectEstimationID)%>' />
< / DIV>
< / ItemTemplate中>
< / ASP:的TemplateField>
试试这个,
我已经仔细阅读线程。从code和说明,我想你想的一大亮点效果添加到你的GridView的悬停行,是吧?
如果是这样,我建议你使用以下code来实现的:
保护无效GridView1_RowDataBound(对象发件人,GridViewRowEventArgs E)
{
如果(e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add(的onmouseover \"currentcolor=this.style.backgroundColor;this.style.backgroundColor='yellow',this.style.fontWeight='';\");
e.Row.Attributes.Add(的onmouseout,this.style.backgroundColor = currentcolor,this.style.fontWeight ='';);
}
}
它的工作原理我的机器上,我希望这可以帮助你。
如果我误解了你的问题,请随时告诉我。
I have tried all possible ways for this highlighting a row in gridview, I can't be able to achive this.I tried direct CSS-Classes,javascript. Pls note me where I made a mistake. Thanks in advance...
protected void test_databound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.background='#D1DDF1';";
e.Row.Attributes["onmouseout"] = "this.style.background='#EFF3FB';";
//e.Row.Attributes["onmouseover"] = "javascript:SetMouseOver(this)";
//e.Row.Attributes["onmouseout"] = "javascript:SetMouseOut(this)";
//e.Row.Attributes.Add("onmouseover", "className='highlighted1'");
//e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=''");
//e.Row.Attributes.Add("style", "cursor:pointer;");
//e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#000000'");
//e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#000000'");
//e.Row.Attributes.Add("style", "cursor:pointer;");
//e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#000000'");
//e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle");
//e.Row.Attributes.Add("style", "cursor:pointer;");
}
//e.Row.Attributes.Add("onmousedown", "IsMouseDown(this,true)");
//e.Row.Attributes.Add("onmouseup", "IsMouseDown(this,true)");
//e.Row.Attributes.Add("onmouseover", "HighlightRow(this,true)");
//foreach (GridViewRow grow in gvCatalogList.Rows)
//{
// e.Row.Attributes.Add("onmousedown", "IsMouseDown(this)");
// e.Row.Attributes.Add("onmouseup", "IsMouseDown(this)");
// grow.Attributes["onmouseover"] = "highlight(this, true);";
// grow.Attributes["onmouseout"] = "highlight(this, false);";
// HttpResponse myHttpResponse = Response;
// HtmlTextWriter myHtmlTextWriter = new HtmlTextWriter(myHttpResponse.Output);
// grow.Attributes.AddAttributes(myHtmlTextWriter);
//}
}
This is my design page
<asp:GridView ID="gvCatalogList" GridLines="None" runat="server" AutoGenerateColumns="False"
PageSize="5" AllowPaging="true" OnPageIndexChanging="OnPageIndexChanging_gvCatalogList"
OnRowDataBound="test_databound">
<FooterStyle CssClass="pagination-flickr" />
<PagerStyle CssClass="pagination-flickr" HorizontalAlign="Center" />
<Columns>
<asp:TemplateField HeaderText="Estimation ID">
<HeaderStyle Wrap="true" Width="10%" />
<ItemTemplate>
<div style="width: 40px; white-space: normal">
<asp:Label ID="label1" Text='<%# Eval("ProjectEstimationVersionID") %>' runat="server"></asp:Label>
<asp:HiddenField ID="hiddenEstimationID" runat="server" Value='<%# Eval("ProjectEstimationID") %>' />
</div>
</ItemTemplate>
</asp:TemplateField>
Try this,
I have read the thread carefully. From your code and description, I think you want to add a highlight effect to the hover row of your GridView, is right?
If so, I suggest you to use the following code to achieve:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='yellow',this.style.fontWeight='';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
}
}
It works on my machine, and I hope this helps for you.
If I’ve misunderstood your problem, please feel free to let me know.
这篇关于的onmouseover,属性的onmouseout没有在GridView的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!