使用JavaScript填充Gridview [英] Populate Gridview using javascript

查看:47
本文介绍了使用JavaScript填充Gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为job Creation的表单名称,另一个是JobCreation Popup

在创建工作"中,我具有添加"按钮,一些文本框和一个gridview

当我单击此添加按钮时

它会显示一个带有两个按钮的弹出窗口.

一个按钮是直接工作,另一个按钮是 FromQuote

当我单击报价时,它将显示带有报价详细信息的网格视图,其中包含 JobNo

当我选择gridview时,应关闭弹出窗口,并应填充行
在父窗体的gridview中.让我们把它们放在同一列.但事实并非如此

这是我背后的代码

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

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);




这是我的javaScript.

我可以将值添加到文本框,但是我想将其放在gridview中




This is my javaScript.

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

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();
}

推荐答案

此javascript函数以gridview名称和源文本框值作为参数,假定gridview已被索引列填充.它写入gridview字段:


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 :


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;
            }
        }
    }


这篇关于使用JavaScript填充Gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆