ASP.NET - Popup to display dynamic message in gridview on click of a Link button

Asked By Giri on 22-Dec-10 05:36 AM
Hi

I need do display a popup message (feedback) on click of linkbutton in gridview
my Aspx.cs code

protected void gridstdnt_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)

{

if (e.CommandName == "View")

{

int RowID = e.Item.ItemIndex;

int StudId = int.Parse(gridstdnt.Items[RowID].Cells[0].Text.Trim());

Session["StudId"] = StudId;






LinkButton lnkstdntview = (LinkButton)e.Item.FindControl("lnkstdntview");



lnkstdntview.OnClientClick = "javascript:popup_window=window.open('popupfeedback.aspx?StudentId=" + Session["StudId"] + "','popup_window','width=350,height=150,top=150,left=625,scrollbars=1');popup_window.focus()";
}
}

Aspx code

<asp:TemplateColumn HeaderText="View Feed Back">

<ItemTemplate>

<asp:Label ID="lblstudentid" runat="server" Visible="false" Text='<%#DataBinder.Eval(Container, "DataItem.StudentId")%>'></asp:Label>







<asp:LinkButton ID="lnkstdntview" runat="server" CommandName="View" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.StudentId")%>'>View</asp:LinkButton>





</ItemTemplate>

</asp:TemplateColumn>

With this code iam getting the same msg(feedback) for all rows

Regards
Babu










Rohan Dave replied to Giri on 22-Dec-10 05:39 AM
have you written any code in popupfeedback.aspx to show feedback for a particular student ?
Giri replied to Rohan Dave on 22-Dec-10 05:41 AM
Yes
Iam passing studentid and getting the feeback  and binding it to a lable

lblFeedback.Text = dt.Rows[0]["Feedback"].ToString();


Rohan Dave replied to Giri on 22-Dec-10 06:05 AM
just make sure that your student id has feedback in database and you have written a correct query.
Reena Jain replied to Giri on 22-Dec-10 06:06 AM
hi,

use javascript alert message for this

<asp:LinkButton ID="lnkstdntview" runat="server" CommandName="View" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.StudentId")%>'
onclick="javascript:alert('Your message here');">
View</asp:LinkButton>


hope this will help you
Giri replied to Reena Jain on 22-Dec-10 06:18 AM
Hi
How to pass the value for this

javascript:alert('Your message here');">

In Place of Your message here - (i need to bind the value from database)
Reena Jain replied to Giri on 22-Dec-10 08:59 AM
hi,

try this

<asp:LinkButton ID="lnkstdntview" runat="server" CommandName="View" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.StudentId")%>'
onclick="javascript:alert('"+ <%#DataBinder.Eval(Container, "DataItem.StudentId")%>+" here');">
View</asp:LinkButton>


hope this will help you