Mouseover mouseout and select on nested data list in asp.net

asniz78

New Member
I have a nested datalist and want to add mouse hover effect here is the view
TuiZk.png
the asp codes:\[code\] <asp:DataList ID="parentDataList" runat="server" DataKeyField="baslikId" Width="100%" OnItemDataBound="parentDataList_ItemDataBound"> <ItemTemplate> <div style="background-color: #a4d4ff; vertical-align: text-bottom"> <table> <tr> <td style="width: 1050px"> <%# Eval("baslikId")%>.) <%# DataBinder.Eval(Container.DataItem, "baslik") %> </td> <td style="width: 100px; padding-right: 10px:" align="right"> <asp:CheckBox ID="cbSec" runat="server" OnCheckedChanged="cbSec_CheckedChanged" AutoPostBack="true" Text="Se?" TextAlign="Left" /> <asp:HiddenField ID="hiddenBaslikId" runat="server" Value='http://stackoverflow.com/questions/12615618/<%# Eval("baslikId") %>' /> </td> </tr> </table> </div> <asp:DataList ID="nestedDataList" runat="server" OnItemDataBound="nestedDataList_ItemDataBound"> <ItemTemplate> <div style="background-color: AliceBlue"> <table> <tr> <td style="width: 1050px"> <%# Eval("maddeId")%>.) <%# Eval("madde")%> </td> <td style="width: 1px"> <asp:CheckBox ID="cbTamam" runat="server" TextAlign="Left" /> <asp:HiddenField ID="hiddenMaddeId" runat="server" Value='http://stackoverflow.com/questions/12615618/<%# Eval("maddeId") %>' /> </td> </tr> </table> </div> </ItemTemplate> <HeaderStyle Font-Bold="true" Font-Names="Arial" /> <ItemStyle Font-Names="Arial" Font-Size="Small" /> </asp:DataList> </ItemTemplate> <HeaderStyle Font-Bold="true" Font-Names="Arial" /> <ItemStyle Font-Names="Arial" Font-Size="Small" /> </asp:DataList>\[/code\]and code behind\[code\] public void BindParentDataList(){ cc.sorgu = "SELECT a, bFROM tbla WHERE birimId = " + ddlBirim.SelectedValue; parentDataList.DataSource = cc.Dt(cc.sorgu); parentDataList.DataBind(); if (parentDataList.Items.Count > 0) { cbTumunuSec.Visible = true; } else { cbTumunuSec.Visible = false; } // foreach loop over each item of DataList control foreach (DataListItem Item in parentDataList.Items) { BindNestedDataList(Item.ItemIndex); }}public void BindNestedDataList(int ItemIndex){ // get CategoryID value for the current datalist item // DataKeys collection object returns the associated value // at specified Item Index of DataList int CategoryID = Convert.ToInt32(parentDataList.DataKeys[ItemIndex]); // findControl function to get the nested datalist control DataList nestedDataList = (DataList)parentDataList.Items[ItemIndex].FindControl("nestedDataList"); cc.sorgu = string.Format("SELECT c, bFROM tblb WHERE birimId = {0} AND baslikId = {1}", ddlBirim.SelectedValue, CategoryID); nestedDataList.DataSource = cc.Dt(cc.sorgu); nestedDataList.DataBind();}\[/code\]once for all I am trying to use theese lines to make mouse effect but they doesnt work\[code\] protected void parentDataList_ItemDataBound(object sender, DataListItemEventArgs e){ if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { e.Item.Attributes["onmouseover"] = "if(this.style.backgroundColor!='silver'){this.style.backgroundColor='#E2E2E2';}this.style.cursor='hand';"; e.Item.Attributes["onmouseout"] = "if(this.style.backgroundColor!='silver'){this.style.backgroundColor='white';}"; e.Item.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.parentDataList, "Select$" + e.Item.ItemIndex); }}protected void nestedDataList_ItemDataBound(object sender, DataListItemEventArgs e){ DataList nestedDataList = (DataList)parentDataList.Items[0].FindControl("nestedDataList"); if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { e.Item.Attributes["onmouseover"] = "if(this.style.backgroundColor!='silver'){this.style.backgroundColor='#E2E2E2';}this.style.cursor='hand';"; e.Item.Attributes["onmouseout"] = "if(this.style.backgroundColor!='silver'){this.style.backgroundColor='white';}"; e.Item.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(nestedDataList, "Select$" + e.Item.ItemIndex); }}\[/code\]and additionally while I click on any row I want to check selected rows checkboxThanks for replies
 
Back
Top