Becky Bloomwood

Becky Bloomwood

  • NA
  • 119
  • 285.8k

Click on ID hyperlink and direct to another page to view records

Feb 14 2011 2:34 AM

Hi,

in my reqirement, I have 2 pages in which the first page is known as: Contract Management.aspx.

In Contract management.aspx, I have a search panel that allows user to input search criteria and click on the search btn. Once the search btn is activated, a grid view called gvContract will be populated with data. In the Contract ID, it contains a list of id that are hyperlinked.Example: 8.3.2.5,  8.3.2.6 -->Hyperlinked.

Once user clicks on the hyperlink, they will be naviagte to another page to view specific details tied to each individual contract id. This page is known as: ContractThreeGridView.aspx. In these page, it contains Critical terms grid view, uploaded documents grid view and checklist grid view. These 3 grid views allows user to insert,update or delete records.
This is my business logic for the gvContract:

 

protected void gvContract_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
GridView header = (GridView)sender;
GridViewRow gvr = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell tCell = new TableCell();
tCell.Text = "Contract Management";
tCell.ColumnSpan = 14;
tCell.HorizontalAlign = HorizontalAlign.Left;
tCell.CssClass = "trWithBorder";
gvr.Cells.Add(tCell);
// Add the Merged TableCell to the GridView Header









Table tbl = gvContract.Controls[0] as Table;
if (tbl != null)
{
tbl.Rows.AddAt(0, gvr);
}
}
if (e.Row.RowType.Equals(DataControlRowType.DataRow))
{
DataRowView objDRV = (DataRowView)e.Row.DataItem;
HyperLink objHlink = (HyperLink)e.Row.FindControl("hlContract");
string strPagePath = "";
 
 
 
 
strPagePath = "http://localhost:1973/VRM_WebSite/app/vrm/ContractThreeGridView.aspx?ContractId=" + objDRV["ContractId"].ToString();
 
objHlink.NavigateUrl = strPagePath;
objHlink.Target = "_self";
}

In my seond page, i have defined:

 

protected void Page_Load(object sender, EventArgs e)
{
//string strContractId = Request.QueryString["ContractId"].ToString();

//string cid = Convert.ToString(Request.QueryString["ContractId"]);

//if (cid != null)

//{

// Response.Write("Fetch Records on the basis of ContracID " + cid);

//}

 
 
if (!IsPostBack)
{
//Set the sortExpression

ViewState[this.ToString() + "_SortExpression1"] = "Terms";
ViewState[this.ToString() + "_SortDirection1"] = "ASC";
//Set the sortExpression

ViewState[this.ToString() + "_SortExpression2"] = "FileName";
ViewState[this.ToString() + "_SortDirection2"] = "ASC";
//Set the sortExpression

ViewState[this.ToString() + "_SortExpression3"] = "Item";
ViewState[this.ToString() + "_SortDirection3"] = "ASC";
 
 
 
//populate the criticalterms datatable

DataTable tmpdt = vrmdb.Get_CriticalTerms().Tables[0];
tmpdt.PrimaryKey = new DataColumn[] { tmpdt.Columns[0] };
ViewState[viewStateGVName] = tmpdt;
//populate the uploadeddocuments datatable

DataTable tmpdtt = vrmdb.Get_UploadedDocuments().Tables[0];
tmpdtt = new DataTable();
tmpdtt = vrmdb.Get_UploadedDocuments().Tables[0];
tmpdtt.PrimaryKey = new DataColumn[] { tmpdtt.Columns[0] };
ViewState[viewStateGVUDName] = tmpdtt;
//populate the uploadeddocuments datatable

DataTable tmpCdt = vrmdb.Get_Checklist().Tables[0];
tmpCdt = new DataTable();
tmpCdt = vrmdb.Get_Checklist().Tables[0];
tmpCdt.PrimaryKey = new DataColumn[] { tmpCdt.Columns[0] };
ViewState[viewStateGVCLName] = tmpCdt;
 
 
 
BindGrid();
BindGrid1();
BindGrid2();
string strContractId = Request.QueryString["ContractId"].ToString();  //This is one is to get the contract id parmater
 
}
}
When I perform an insert req for one of the grid view and click on the Add New link btn defined at the footer, there is an error indicating:
 

Server Error in '/VRM_WebSite' Application.

Object reference not set to an instance of an object.


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 83:                 BindGrid1();
Line 84:                 BindGrid2();
Line 85:                 string strContractId = Request.QueryString["ContractId"].ToString();
Line 86: 
Line 87: 

Source File: c:\Users\L31410\Desktop\Peggie\Peggie\Deployment Source\Phase 1\Deployment 25 Nov for StarHub\VS Projects Source\VRM_WebSite\app\vrm\ContractThreeGridView.aspx.cs    Line: 85

I am not sure of how to resolve it.Thanks!











































 

Answers (6)