Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate a popup window from radgrid row

Status
Not open for further replies.

sirnose1

Programmer
Nov 1, 2005
133
US
I am trying to populate a popup window with a value from a cell on a selected row. I am able to get the popup window to open, but the problem lies in that there are some rows with no ID associated, so I need to get the text in the cell by the index. How do I get the cell text into the popup? Here is my code-behind:

//Rows with N/A denote no unique ID colum
if (claimrow1 == "N/A")
{
GridDataItem item = (GridDataItem)e.Item;
TableCell raw_data = item["raw_data"];
string rawData = ((DataRowView)e.Item.DataItem)["raw_data"].ToString();
hlACPMSDetail.Visible = true;
hlACPMSDetail.Attributes["href"] = "#";
//hlACPMSDetail.Attributes["onclick"] = string.Format("return openClaimDetail('{0}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ACPMSID"]);
hlACPMSDetail.Attributes["onclick"] = string.Format("return openClaimDetail('{0}');", e.Item.ItemIndex); // e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ACPMSID"]);

Thanks in advance

}
 
You will have to construct an if statement
Code:
if (you have an ID)
{
hlACPMSDetail.Attributes["onclick"] = string.Format("return openClaimDetail('{0}');", e.Item.ItemIndex);
}
else
{
 //Here  you will have to loop through the cells in the radgrid row and get each value.  You will then have to construct a string with query string parameters you will pass to your pop-up window.  Then in your popup you can check for an ID.  If you have it, use it, otherwise use these parameters.
}
 
Thanks for the response. We decided to use a view with this that has the key for all rows. That's no longer the issue. I am kind of new to javascript and what I'm trying to accomplish is to send 2 parameters (ID, raw_data) into a querystring, bur it either won't open the popup or the radgrid will not load and its a little urgent. Thanks again.

My jasvscript code is:
function openTransactionDetail(logID) {
window.open("/CMS/EDITransactionDetail.aspx?LogID=" + logID + "&raw_data=0","EDITransactionDetail","width=700px, height=400px, resizable=1, scrollbars=1");

My code behind:

protected void gridAdvSearchResults_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem gridItem = (GridDataItem)e.Item;
DataRowView row = (DataRowView)gridItem.DataItem;

HyperLink hlACPMSDetail = (HyperLink)e.Item.FindControl("hlACPMSDetail");

String claimrow1 = Convert.ToString(row["LogID"]);
//Rows with N/A denote no unique ID colum
//if (claimrow1 != "N/A")
{
GridDataItem item = (GridDataItem)e.Item;
TableCell raw_data = item["raw_data"];
string rawData = raw_data.Text;
hlACPMSDetail.Visible = true;
hlACPMSDetail.Attributes["href"] = "#";
hlACPMSDetail.Attributes["onclick"] = string.Format("return openTransactionDetail('{0}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["LogID"]);

}
//else{
// Int64 claimRow = Convert.ToInt64(row["ACPMSID"]);


// if (hlACPMSDetail != null)
// {

// hlACPMSDetail.Attributes["href"] = "#";
// hlACPMSDetail.Attributes["onclick"] = string.Format("return openClaimDetail('{0}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ACPMSID"]);
// }
//}


}

}
// Int64 claimRow = Convert.ToInt64(row["ControlID"]);
// HyperLink hlClaimDetail = (HyperLink)e.Item.FindControl("hlClaimDetail");
// if (hlClaimDetail != null)
// {
// hlClaimDetail.Attributes["href"] = "#";
// hlClaimDetail.Attributes["onclick"] = String.Format("return openClaimDetail('{0}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ClaimID"]);
// }
// }
//}

Any help you could give me would be a big help. Thanks.
 
I would assume it is a problem with the path to the page you want to open:
window.open("/CMS/EDITransactionDetail.aspx?LogID=" + logID + "&raw_data=0","EDITransactionDetail","width=700px, height=400px, resizable=1, scrollbars=1");

It is probably not finding "/CMS/EDITransactionDetail.aspx" from where you are trying to open it. We always add the application path before it, someting like this:

"/YourAppNameHere/CMS/EDITransactionDetail.aspx"

Try that.
 
OK, now when I set raw_data field to grab the cell data from the radgrid, I get an "undefined" error for the raw_data. Is there something I am missing here by refactoring this function?
function openTransactionDetail(logID, raw_data) {
window.open("/CMS/EDITransactionDetail.aspx?LogID=" + logID + "&raw_data=" + raw_data,"EDITransactionDetail","width=700px, height=400px, resizable=1, scrollbars=1");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top