ImageButton in gridview

Posted by Kashif under ASP.NET on 7/8/2013 | Points: 10 | Views : 2271 | Status : [Member] | Replies : 7
i have a imagebutton in gridview,i want to delete row of gridview by clicking on imagebutton,i have tried many codes but it is not working,i am not using any sqldatasource or store procedure.

Please let me know ,how can i do this,give me an idea or code without store procedure or without using sqldatasource.......
thanks




Responses

Posted by: Vuyiswamb on: 7/8/2013 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Can we see your code ?

Thank you for posting at Dotnetfunda
[Administrator]

Kashif, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kashif on: 7/9/2013 [Member] Starter | Points: 25

Up
0
Down
here is my gridview code........now i am searching imagebutton function to be in aspx.cs




<asp:GridView runat="server" ID="gvrecords" AutoGenerateColumns="False"
DataKeyNames="category_id" CssClass="list" GridLines="None">
<Columns>
<asp:TemplateField HeaderStyle-CssClass="tableheading" >
<HeaderTemplate>
<asp:CheckBox ID="selectall" onclick="javascript:SelectAllCheckboxes(this);" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkdelete" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="category_name" HeaderText="Category Name"
HeaderStyle-CssClass="tableheading" ItemStyle-CssClass="left" >
<HeaderStyle CssClass="tableheading"></HeaderStyle>

<ItemStyle CssClass="left" ></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="category_descrption"
HeaderText="Category Description" HeaderStyle-CssClass="tableheading" SortExpression="category_descrption" />
<asp:ImageField DataImageUrlField="category_image" HeaderStyle-CssClass="tableheading" HeaderText="Category Image">
</asp:ImageField>
<asp:BoundField DataField="sort_order" HeaderText="Sort Order"
HeaderStyle-CssClass="tableheading" SortExpression="sort_order" />
<asp:TemplateField HeaderText="Actions" HeaderStyle-CssClass="tableheading" >
<ItemTemplate >
<a href ='<%#"edit_categories.aspx?category_id="+DataBinder.Eval(Container.DataItem,"category_id") %>'><img src="images/edit.gif" /></a>
&nbsp;&nbsp;
<asp:ImageButton runat="server"
CommandName='DeleteItem'

CommandArgument='<%# Eval("category_id") %>'
ImageUrl="images/delete_on.gif"
/>
</ItemTemplate>

<HeaderStyle CssClass="tableheading"></HeaderStyle>
</asp:TemplateField>
</Columns>

</asp:GridView>

Kashif, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 7/9/2013 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Nothing will happen because there is no ItemCommand Event to Handle your Command :)


Thank you for posting at Dotnetfunda
[Administrator]

Kashif, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kashif on: 7/9/2013 [Member] Starter | Points: 25

Up
0
Down
i am unable to learn this ,i have struggling in this small thing for a week...please let me know the proper tutorial where i can delete a row by clicking on imagebutton ...nd again i am not using any store procedure or sqldatasoure...
if u can help me ..i will be thankful

Kashif, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 7/9/2013 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
meet me in Skype i will assist you , "vuyiswamb"


Thank you for posting at Dotnetfunda
[Administrator]

Kashif, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kashif on: 7/12/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks ,i have solved my problem without using imagbutton

Kashif, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 7/12/2013 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Congrats, please mark your post as "Resolved"

Thank you for posting at Dotnetfunda
[Administrator]

Kashif, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response