Click here to Skip to main content
15,922,894 members
Please Sign up or sign in to vote.
4.33/5 (2 votes)
See more:
I have a form name called job Creation and another one is a JobCreation Popup

In Job Creation i have Add button, Some text boxes and a gridview

when i click this add button

it will show a Popup Which has two button.

One button is Direct job And the other one is FromQuote

When i click a quote it will show a gridview with Quote details which has JobNo,etc

When i select the gridview the Popup should be closed and the row should be populated
in the gridview of the Parent form. Lets take both has same column. but is not so

This is My code behind

C#
string EnqNo = string.Empty;
       string QuoteNo = string.Empty;
       string JobNo = string.Empty;
       string ShipType = string.Empty;
       string CorgoType = string.Empty;
       string CustCode = string.Empty;
       string CustName = string.Empty;
       string CustBranchCode = string.Empty;
       string CustBranchName = string.Empty;
       if (grdJobRegister.SelectedRow != null)
       {

           if (grdJobRegister.SelectedRow.Cells[1].Text != null)
           {
               EnqNo = grdJobRegister.SelectedRow.Cells[1].Text;

           }
           if (grdJobRegister.SelectedRow.Cells[2].Text != null)
           {
               QuoteNo = grdJobRegister.SelectedRow.Cells[2].Text;

           }
           if (grdJobRegister.SelectedRow.Cells[3].Text != null)
           {
               JobNo = grdJobRegister.SelectedRow.Cells[3].Text;

           }
           if (grdJobRegister.SelectedRow.Cells[4].Text != null)
           {
               ShipType = grdJobRegister.SelectedRow.Cells[4].Text;

           }
           if (grdJobRegister.SelectedRow.Cells[5].Text != null)
           {
               CorgoType = grdJobRegister.SelectedRow.Cells[5].Text;

           }
           if (grdJobRegister.SelectedRow.Cells[6].Text != null)
           {
               CustCode = grdJobRegister.SelectedRow.Cells[6].Text;

           }
           if (grdJobRegister.SelectedRow.Cells[7].Text != null)
           {
              CustName = grdJobRegister.SelectedRow.Cells[7].Text;

           }
           if (grdJobRegister.SelectedRow.Cells[8].Text != null)
           {
               CustBranchCode = grdJobRegister.SelectedRow.Cells[7].Text;

           }
           if (grdJobRegister.SelectedRow.Cells[9].Text != null)
           {
               CustBranchName = grdJobRegister.SelectedRow.Cells[7].Text;

           }
           ClientScript.RegisterStartupScript((typeof(GridView)), "JavaScript", "GetGridValue('" + EnqNo + "','" + QuoteNo + "','" + JobNo + "','" + ShipType + "','" + CorgoType + "','"+CustCode+"','"+CustName+"','"+CustBranchCode+"','"+CustBranchName+"');",true);



This is my javaScript.

I could able to put values to textboxes but i want to put this in gridview

C#
function GetGridValue(EnqNo,QuoNo,JobNo,ShipType,CorgoType,CustCode,CustName, CustbranchCode, CustBranchName)
  {
  var f= document.forms("frmjobCreation");
  window.opener.document.frmjobCreation.txtEnquiryNo.value=EnqNo;
  window.opener.document.frmjobCreation.txtQuoteNo.value=QuoNo;
  window.opener.document.frmjobCreation.txtJobNo.value=JobNo;
  window.opener.document.frmjobCreation.txtJobCustomerCode.value=CustCode;
  window.opener.document.frmjobCreation.txtJobCustomerName.value=CustName;
  window.opener.document.frmjobCreation.txtConsigneeCode.value=CustCode;
  window.opener.document.frmjobCreation.txtConsigneeName.value=CustName;
  window.opener.document.frmjobCreation.txtConsigneeBranchCode.value=CustbranchCode
  window.opener.document.frmjobCreation.txtConsigneeBranchName.value=CustBranchName;
//window.opener.document.frmjobCreation.btnGetServiceCommodity.style.visibility="visible";
//var aa = window.opener.document.forms("frmjobCreation");
//  var btn = btn.elements["btnGetServiceCommodity"];
//  btn.style.visibility="visible";

if(ShipType=='Sea')
{
var f = window.opener.document.forms("frmjobCreation");
var radioButtonList=f.elements["rbShipmentType"];
radioButtonList[0].checked=true;
}
if(ShipType=='Air')
{
var f = window.opener.document.forms("frmjobCreation");
var radioButtonList=f.elements["rbShipmentType"];
radioButtonList[0].checked=true;
}
if(CorgoType=='Freehand')
{
var f = window.opener.document.forms("frmjobCreation");
var radioButtonList=f.elements["rbFreeHandorNominatedCorgo"];
radioButtonList[0].checked=true;
}
if(CorgoType=='Nominated')
{
var f = window.opener.document.forms("frmjobCreation");
var radioButtonList=f.elements["rbFreeHandorNominatedCorgo"];
radioButtonList[1].checked=true;
}
self.close();
}
Posted

1 solution

this javascript function take as argument gridview name and source textbox value, it is assumed that gridview is already filled with index column. It writes gridview fields :


C#
function fillAll(theGrid, frstTxtBox)
    {
        var tbl = document.getElementById(theGrid);
        for(var i = 1; i< tbl.rows.length;i++)
        {
            if (document.getElementById('index').value != 0 )
            var inptfld = document.getElementByName('<%= txtRequestDate.ClientID %>')
            {
                inptfld.value = document.getElementById(frstTxtBox).value;
            }
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900