This is my UserRoleList.aspx file:
<%@ Page Title="" Language="C#" MasterPageFile="~/Forms/RolesMgt/MasterRoles.master"
AutoEventWireup="true" CodeFile="UserRoleList.aspx.cs" Inherits="Forms_RolesMgt_RoleList_UserRoleList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div style="height: 679px">
<p class="Sub_title">
List of Users And Click To View Roles Assigned To Them
</p>
<asp:GridView ID="UserGridView" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="false" OnSelectedIndexChanged="UserNameIdGrdView_SelectedIndexChanged">
<Columns>
<asp:BoundField ItemStyle-Width="150px" DataField="UserId" HeaderText="User Id" />
<asp:BoundField ItemStyle-Width="150px" DataField="UserName" HeaderText="User Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnSelect" runat="server" Text="Select" CommandName = "Select" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</div>
<asp:Button ID="btnSend" runat="server" Text="Send Selected Row" OnClick = "Send" />
</asp:Content>
This is the UserRoleList.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Forms_RolesMgt_RoleList_UserRoleList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["userName"] == null)
Response.Redirect("~/Login.aspx");
if (!Page.IsPostBack)
{
if (!Page.User.IsInRole("Others_Roles_Add"))
Response.Redirect("~/unauthorized.aspx");
getUserRoles();
}
}
private void getUserRoles()
{
DSRolesTableAdapters.aspnet_RoleUsersTableAdapter userRoleAdapter = new DSRolesTableAdapters.aspnet_RoleUsersTableAdapter();
DataTable dt= new DataTable();
dt = userRoleAdapter.GetDataUser();
UserGridView.DataSource = dt;
UserGridView.DataBind();
}
protected void UserNameIdGrdView_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Send(object sender, EventArgs e)
{
if (UserGridView.SelectedRow != null)
{
Server.Transfer("~/Forms/RolesMgt/RoleList/Default.aspx");
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please select a row.')", true);
}
}
}
This is the next page where i want all the controls of the selected row to be transferred. I tried by out ur different tutorial, it works when i use out of my project but did not work when i use it in my working project.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlTypes;
public partial class Forms_RolesMgt_RoleList_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (this.Page.PreviousPage != null)
{
GridView GridView1 = (GridView)this.Page.PreviousPage.FindControl("UserGridView");
GridViewRow selectedRow = GridView1.SelectedRow;
Response.Write("CustomerId: " + selectedRow.Cells[0].Text + "<br />");
Response.Write("City: " + selectedRow.Cells[1].Text + "<br />");
}
}
}
Please help me out to figure out this problem, I tried the tutorials as u mentioned above but showing the same error.
Thank you