gpinfotech
asked on
Grid view data binding
Hi experts,
I'm using asp:BoundField and asp:TemplateField combination to bind the data and edit image to the grid view, grid is loading but row command event not firing
I'm using asp:BoundField and asp:TemplateField combination to bind the data and edit image to the grid view, grid is loading but row command event not firing
Hello:
You need to add an event handler in you gridview for the RowCommand event
OnRowCommand="MyMethod"
Best regards
You need to add an event handler in you gridview for the RowCommand event
OnRowCommand="MyMethod"
Best regards
****** aspx ********
<asp:GridView runat="server" ID="gv_financials" AutoGenerateColumns="false" OnRowCommand="MyMethod">
<Columns>
<asp:BoundField DataField="CreateDate" HeaderText="Date"/>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:TemplateField HeaderText="T" ItemStyle-Width="100px">
<ItemStyle Width="10px" HorizontalAlign="Center" />
<HeaderStyle Width="10px" HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label runat="server" ID="lblType" Font-Bold="true"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemStyle Width="10px" />
<ItemTemplate>
<table width="100%">
<tr>
<td>
<asp:ImageButton runat="server" ID="btnView" ImageUrl="~/images/view.png" CommandName="view" CommandArgument='<%# Container.DataItemIndex %>'></asp:ImageButton>
</td>
<td>
<asp:ImageButton runat="server" ID="btnCopy" ImageUrl="~/images/copy.png" CommandName="copy"
CommandArgument='<%# Container.DataItemIndex %>' OnClientClick="return confirm_copy();">
</asp:ImageButton>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
**** vb code behind************
Protected Sub gv_financials_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gv_financials.RowCommand
If e.CommandName = "view" Then
'ur code abt view
ElseIf e.CommandName = "copy" Then
'ur code to copy
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
abhinayp:
Thanks for the tip. I work mostly with c# and sometimes forget the differences. ;-)
Thanks for the tip. I work mostly with c# and sometimes forget the differences. ;-)
ASKER
Hi thank u for ur reply
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Open in new window