TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Harshal Kulkarni
NA
26
9.5k
how to handle multiple link button event in gridview
Jan 24 2017 12:33 AM
Hello everyone, i have multiple link buttons in gridview and have to write event for selected link button. All buttons are fire different query and output will be send on another page.
This is my HTML code:
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" CssClass="Grid" ondatabound="GridView1_DataBound"
onrowcreated="GridView1_RowCreated" onrowdatabound="GridView1_RowDataBound"
onselectedindexchanged="GridView1_SelectedIndexChanged" Width="152px"
onrowcommand="GridView1_RowCommand">
<Columns>
<asp:BoundField runat="server" DataField="LOSS" HeaderText="Loss Range" />
<asp:TemplateField HeaderText="sd">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="sd" >LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="scd">
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="scd">LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="cd">
<ItemTemplate>
<asp:LinkButton ID="LinkButton3" runat="server" CommandName="cd">LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="nd">
<ItemTemplate>
<asp:LinkButton ID="LinkButton4" runat="server" CommandName="nd">LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ed">
<ItemTemplate>
<asp:LinkButton ID="LinkButton5" runat="server" CommandName="ed">LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
C# Code:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "sd")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
if (row.Cells[1].Text != " ")
{
e.Row.Cells[1].Attributes.Add("onClick", "openWindow_Requests('" + division + "," + category + "," + month + "," + year + "')");
}
}
}
Thanks in advanced.
Reply
Answers (
1
)
Mail issue using smtp
How to learn ASP.net and ASP.net MVC