code of aspx page
<asp:GridView ID="gvFacultyReg" runat="server" AutoGenerateColumns="False" AllowPaging="True" OnPageIndexChanging="gvFacultyReg_PageIndexChanging" PageSize="10" onrowcommand="gvFacultyReg_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lblName" runat="server" Text='<%#Eval("NAME") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="UserID">
<ItemTemplate>
<asp:Label ID="lblUserID" runat="server" Text='<%#Eval("USER_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email ID">
<ItemTemplate>
<asp:Label ID="lblEmail" runat="server" Text='<%#Eval("EMAIL_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Contact No">
<ItemTemplate>
<asp:Label ID="lblContactNo" runat="server" Text='<%#Eval("CONTACT_NO") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField DataTextField="" DataNavigateUrlFields="USER_ID" DataNavigateUrlFormatString="faculty-profile.aspx?fid={0}"
Text="View"></asp:HyperLinkField>
<asp:TemplateField HeaderText ="In College Profile">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="ViewProfile" CommandArgument='<%#Container.DataItemIndex %>'>View</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
-------------------------------------------------------------------------------------------------------
code on .CS page
protected void gvFacultyReg_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ViewProfile")
{
int i = int.Parse(e.CommandArgument.ToString());
Label FACULTY_ID = (Label)gvFacultyReg.Rows[i].FindControl("lblFACULTY_ID");
LinkButton LinkButton1 = (LinkButton)gvFacultyReg.Rows[i].FindControl("LinkButton1");
int temp = vd.INS_COLLEGE_FACULTY_PROFILE(FACULTY_ID.Text.Trim(), ViewState["collegeId"].ToString(), "Y", ViewState["collegeTrackingId"].ToString().Trim(), ViewState["userId"].ToString().Trim());
if (temp > 0)
{
LinkButton1.CommandName = "Remove";
}
}
if (e.CommandName == "Remove")
{
}
}
No comments:
Post a Comment