<asp:UpdatePanel ID="UpdatePanel3" runat="server"> <ContentTemplate> <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" ShowFooter="True" OnPageIndexChanging="GridView1_PageIndexChanging" Style="table-layout: fixed;" CssClass="mGrid" DataKeyNames="AreaID" PagerStyle-CssClass="pgr" ShowHeader="False" AlternatingRowStyle-CssClass="alt" Width="652px" Height="625px" OnRowDataBound="GridView1_RowDataBound" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"> <%-- <BoundaryStyle BorderColor="Gray" BorderStyle="Solid" BorderWidth="1px" />--%> <AlternatingRowStyle CssClass="alt" /> <Columns> <asp:TemplateField ItemStyle-Width="43px"> <ItemTemplate> <%#Container.DataItemIndex+1 %> </ItemTemplate> <ItemStyle Width="43px" /> </asp:TemplateField> <asp:BoundField HeaderText="ID" DataField="AreaID" HeaderStyle-HorizontalAlign="Left" Visible="false"> <HeaderStyle HorizontalAlign="Left" /> </asp:BoundField> <asp:TemplateField ShowHeader="False"> <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="" Text='<%# Eval("Area") %>'></asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> <PagerStyle Font-Names="Calibri" Font-Size="12px" Width="303px" BackColor="#000000" HorizontalAlign="Center" ForeColor="White" /> </asp:GridView> <asp:Button ID="btnTest" runat="server" onclick="gridview_click" /> </ContentTemplate> </asp:UpdatePanel>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#ceedfc'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=''"); e.Row.Attributes.Add("style", "cursor:pointer;"); //e.Row.Attributes.Add("onclick", "location='patron_detail.aspx?id=" + e.Row.Cells[0].Text + "'"); e.Row.Attributes["OnClick"] = Page.ClientScript.GetPostBackClientHyperlink(btnTest, , e.Row.RowIndex.ToString()); } } protected void GridView1_OnClick(object sender, EventArgs e){ //{ btnNew.Visible = false; btnUpdate.Visible = true; this.ModalPopupExtender1.Show(); } public class btnTest : Button, IPostBackEventHandler { // Use the constructor to defined default label text. public btnTest() { } // Implement the RaisePostBackEvent method from the // IPostBackEventHandler interface. public void RaisePostBackEvent(string eventArgument) { //You receive the row number here. } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)