Reputation: 3055
<asp:GridView ID="gridPlace" runat="server" AutoGenerateColumns="False" Width="800px"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="5" OnRowDataBound="gridPlace_RowDataBound" OnSelectedIndexChanged="gridPlace_SelectedIndexChanged">
<Columns>
<asp:BoundField HeaderText="DetailID" DataField="PID" />
<asp:BoundField HeaderText="Name" DataField="Name" ControlStyle-Width="200px" />
<asp:BoundField HeaderText="Description" DataField="Description" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="btnEdit" runat="server" ImageUrl="~/Images/Edit.png" ToolTip="Click To Edit this Record" />
</ItemTemplate>
<ItemStyle Width="40px" HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<h2 class="CustomErrorMsg">
No Record Found</h3>
</EmptyDataTemplate>
</asp:GridView>
Here is my html markup for the gridview.RowDatabound event is firing perfectly.Kindly Help
Upvotes: 0
Views: 6837
Reputation: 423
I have had these symptoms using TemplateFields.
TemplateFields allow you to have items in different columns with the same ID - without intellisense highlighting an error.
Under those circumstances, two links with the same ID can prevent the click being resolved.
Ususally this will be a copy and paste error.
Hope this helps someone!
Upvotes: 0
Reputation: 26386
You cannot just click anywhere on a row to fire the event, you will need JavaScript to do that. Think these would help
<asp:GridView Runat="server" ID="GridView1" AutoGenerateSelectButton="true" />
- How to: Enable Default Selection in the GridView Web Server Control
Add
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton CommandName="Select" />
</ItemTemplate>
</asp:TemplateField>
Use JavaScript if you don't want the select button to appear - http://forums.asp.net/t/992062.aspx/1
<asp:CommandField ShowSelectButton="true" ButtonType="Image" />
- http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.commandfield.aspx
Upvotes: 1