M
Mark Rae
Guys,
Apologies for asking this, but it's late and I'm clearly missing something
fairly obvious...
I have an <aspataGrid > control defined thus:
<aspataGrid ID=dgrdResults Runat=server
OnEditCommand="dgrdResults_Edit"
OnPageIndexChanged="dgrdResults_PageIndexChanged"
OnSortCommand="dgrdResults_Sort" OnItemDataBound="dgrdResults_ItemDataBound"
AutoGenerateColumns="False" AllowPaging="true" AllowSorting="true"
PageSize="10" PagerStyle-NextPageText="Next >" PagerStyle-PrevPageText="<
Previous" PagerStyle-HorizontalAlign="Left" PagerStyle-Mode="NumericPages"
HorizontalAlign="Left" DataKeyField="intBusinessIDcnt"
PagerStyle-Font-Size="8" CellPadding="3" BorderWidth="1px"
BorderStyle="Solid">
<HeaderStyle Font-Bold="True" BackColor="#e5e5e5" Font-Name="Verdana"
ForeColor=Black Font-Size="XX-Small" Font-Underline="false"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="intBusinessIDcnt" Visible=False />
<asp:ButtonColumn CommandName="Edit" DataTextField="strBusiness"
HeaderText="Name" SortExpression="strBusiness" ItemStyle-Wrap="False"
HeaderStyle-Wrap="false" />
<asp:BoundColumn DataField="intProjects" HeaderText="Projects"
SortExpression="intProjects" ItemStyle-Wrap="False" HeaderStyle-Wrap="false"
ItemStyle-HorizontalAlign="Right"/>
</Columns>
<ItemStyle Font-Name="Verdana" Font-Size="XX-Small" />
<AlternatingItemStyle BackColor="WhiteSmoke" />
<FooterStyle ForeColor="Black" BackColor="#CCCC99" Font-Size="XX-Small"
Font-Name="Verdana"></FooterStyle>
<PagerStyle HorizontalAlign="Left" ForeColor="Black"
BackColor="White"></PagerStyle>
</aspataGrid>
I'm trying to make its OnEditCommand event fire when a row is clicked. I
know I've done this before, but I can't get it to work tonight...
The dgrdResults_ItemDataBound() method is as follows:
public void dgrdResults_ItemDataBound(object sender, DataGridItemEventArgs
e)
{
if(e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='white'");
}
if(e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='WhiteSmoke'");
}
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='LemonChiffon'");
e.Item.Style["cursor"] = "hand";
e.Item.Attributes["onclick"] =
Page.GetPostBackEventReference(Page.FindControl("dgrdResults"),
"OnEditCommand");
}
}
When I click a row, the page posts back, but doesn't fire the
dgrdResults_Edit event...
Help!
Any assistance gratefully received.
Mark
Apologies for asking this, but it's late and I'm clearly missing something
fairly obvious...
I have an <aspataGrid > control defined thus:
<aspataGrid ID=dgrdResults Runat=server
OnEditCommand="dgrdResults_Edit"
OnPageIndexChanged="dgrdResults_PageIndexChanged"
OnSortCommand="dgrdResults_Sort" OnItemDataBound="dgrdResults_ItemDataBound"
AutoGenerateColumns="False" AllowPaging="true" AllowSorting="true"
PageSize="10" PagerStyle-NextPageText="Next >" PagerStyle-PrevPageText="<
Previous" PagerStyle-HorizontalAlign="Left" PagerStyle-Mode="NumericPages"
HorizontalAlign="Left" DataKeyField="intBusinessIDcnt"
PagerStyle-Font-Size="8" CellPadding="3" BorderWidth="1px"
BorderStyle="Solid">
<HeaderStyle Font-Bold="True" BackColor="#e5e5e5" Font-Name="Verdana"
ForeColor=Black Font-Size="XX-Small" Font-Underline="false"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="intBusinessIDcnt" Visible=False />
<asp:ButtonColumn CommandName="Edit" DataTextField="strBusiness"
HeaderText="Name" SortExpression="strBusiness" ItemStyle-Wrap="False"
HeaderStyle-Wrap="false" />
<asp:BoundColumn DataField="intProjects" HeaderText="Projects"
SortExpression="intProjects" ItemStyle-Wrap="False" HeaderStyle-Wrap="false"
ItemStyle-HorizontalAlign="Right"/>
</Columns>
<ItemStyle Font-Name="Verdana" Font-Size="XX-Small" />
<AlternatingItemStyle BackColor="WhiteSmoke" />
<FooterStyle ForeColor="Black" BackColor="#CCCC99" Font-Size="XX-Small"
Font-Name="Verdana"></FooterStyle>
<PagerStyle HorizontalAlign="Left" ForeColor="Black"
BackColor="White"></PagerStyle>
</aspataGrid>
I'm trying to make its OnEditCommand event fire when a row is clicked. I
know I've done this before, but I can't get it to work tonight...
The dgrdResults_ItemDataBound() method is as follows:
public void dgrdResults_ItemDataBound(object sender, DataGridItemEventArgs
e)
{
if(e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='white'");
}
if(e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='WhiteSmoke'");
}
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='LemonChiffon'");
e.Item.Style["cursor"] = "hand";
e.Item.Attributes["onclick"] =
Page.GetPostBackEventReference(Page.FindControl("dgrdResults"),
"OnEditCommand");
}
}
When I click a row, the page posts back, but doesn't fire the
dgrdResults_Edit event...
Help!
Any assistance gratefully received.
Mark