Site Search

Thursday, June 30, 2011

Adding Image button to data grid view

1.Add image button under template field it will be easier than adding a command field.
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center" Width="35px" />
<ItemTemplate>
<asp:ImageButton ID="selectButton" CommandName="Select" runat="server"/>
ItemTemplate>
asp:TemplateField>
<asp:BoundField DataField="Name">
<HeaderStyle HorizontalAlign="Left" />
asp:BoundField>
<asp:BoundField DataField="Id">
<HeaderStyle HorizontalAlign="Left" />
asp:BoundField>
<asp:BoundField DataField="MainCreditorName">
<HeaderStyle HorizontalAlign="Left" />
asp:BoundField>
Columns>
2.Add the SelectedIndexChanged event and it will fire when you click on image button on the grid.
protected void XXXXXXXXXX_SelectedIndexChanged(object sender, EventArgs e)
{
}
3.You are done

No comments:

Post a Comment