如何通过填充webmethod中的数据表并通过其行为调用来填充数据网格 [英] how to fill a datagrid by filling a datatable in a webmethod and calling by its behavior

查看:71
本文介绍了如何通过填充webmethod中的数据表并通过其行为调用来填充数据网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Mate!,

首先,我有两个网页。一个充当主页面,另一个充当弹出页面。当我单击母版页中的按钮(例如"添加"按钮)时,弹出页面应该打开。当我在弹出页面的文本框中输入一些值后,在弹出页面中单击"提交"按钮时,jscript函数应该采用弹出页面中文本框的值,并将其传递给接受这些文本框的web方法参数。


在webmethod中,我使用从jscript函数收到的参数填充数据表,并将该数据表存储在会话变量中。


在这些操作之后,jscript函数应该关闭弹出窗口应该刷新父窗口,在主页面中使用该数据表填充会话中的数据网格。

i我使用webservice行为从jscript调用webmethod。

Hello Mate!,                       

       First of all i have two webpages. one acts as a master page and other one acts as a popup page. when i click a button (say Add button) in the master page the pop up page should open. and when i click submit button in the pop up page after entering some values in the textboxes of the pop up page, a jscript function should take the values of the text boxes in the pop up page and should pass it to a webmethod which accepts these parameters.
               

                    In the webmethod i am filling a datatable with the parameters that i had received from the jscript function and storing that datatable in a session variable.
     

       
                          after these operation the jscript function should close the popup window and should refresh the parent window making a datagrid in the master page populated with that datatable from session .      

                         i am using the webservice behavior to call the webmethod from jscript .

或者仅当我在执行第一次操作后刷新母版页时,datagird会在弹出页面中填充这些值。

< b>这是将弹出页面中的值传递给Web方法的Jscript函数,当我们单击 时将调用此函数 弹出页面中的提交按钮:

This is the Jscript function that passes the values in the popup page to a web method and this function will be invoked when we click  submit button in the pop up page:

我有使用'opener.submit'来避免一个消息框,说'不能刷新页面而不重新发送信息'。

{

var strtxtCust_cp_code = document.getElementById( " Table1_txtCust_cp_code" ; )。value;

var strtxtCust_cp_code = document.getElementById("Table1_txtCust_cp_code").value;

var strtxtCust_cp_name = document.getElementById( " Table1_txtCust_cp_name" )。value;

var strtxtCust_cp_name = document.getElementById("Table1_txtCust_cp_name").value;

var strtxtCust_cp_desig = document.getElementById( " Table1_txtCust_cp_desig" )。value;

var strtxtCust_cp_desig = document.getElementById("Table1_txtCust_cp_desig").value;

var strtxtcust_cp_ph_no = document.getElementById( " Table1_txtCust_cp_phone_no" ).value;

var strtxtcust_cp_ph_no = document.getElementById("Table1_txtCust_cp_phone_no").value;

var strtxtCust_cp_mobile_no = document.getElementById( " Table1_txtCust_cp_mobile_no" )。value;

var strtxtCust_cp_mobile_no = document.getElementById("Table1_txtCust_cp_mobile_no").value;

var strtxtCust_cp_email_id = document.getElementById( " Table1_txtC ust_cp_email" )。value;

var strtxtCust_cp_email_id = document.getElementById("Table1_txtCust_cp_email").value;

}

{

//调试器;

window 。关();

window.close();

}

这是使用从上面的jscript函数接收的参数填充数据表的web方法:

Dim 删除 As New DataColumn

Dim Delete As New DataColumn

Table6.Columns.Add(删除)

Table6.Columns.Add(Delete)

Table6.Columns.Add(修改)

Table6.Columns.Add(Modify)

Table6.Columns.Add(代码)

Table6.Columns.Add(Code)

Table6.Columns.Add(Name)

Table6.Columns.Add(Name)

Table6.Columns.Add(指定)

Table6.Columns.Add(Designation)

Table6.Columns.Add(电话)

Table6.Columns.Add(Phone)

表6 .Columns.Add(Mobile)

Table6.Columns.Add(Mobile)

Table6.Columns.Add(Email)

Table6.Columns.Add(Email)

Table6.Columns.Add(Remar ks)

Table6.Columns.Add(Remarks)

如果 会话( " CUST_Info" Nothing 然后

If Session("CUST_Info") Is Nothing Then

Table6.Rows.Add (0)

Table6.Rows.Add(0)

Table6.Rows(0).Item( " Delete" )= " Delete.png"

Table6.Rows(0).Item("Delete") = "Delete.png"

表6。行(0).Item( " Modify" )= " Modify.png"

Table6.Rows(0).Item("Modify") = "Modify.png"

Table6.Rows(0).Item( " Name" )= strtxtCust_cp_name

Table6.Rows(0).Item("Name") = strtxtCust_cp_name

Table6.Rows(0).Item( " Phone" )= strtxtcust_cp_ph_no

Table6.Rows(0).Item("Phone") = strtxtcust_cp_ph_no

Table6.Rows(0).Item( " Email" )= strtxtCust_cp_email_id

Table6.Rows(0).Item("Email") = strtxtCust_cp_email_id

Else

Else

Dim i As 整数

Dim i As Integer

i = Table6.Rows.Count

i = Table6.Rows.Count

Table6.Rows.Add(i)

Table6.Rows.Add(i)

Table6.Rows(i).Item( "删除" )= " Delete.png"

Table6.Rows(i).Item("Delete") = "Delete.png"

Table6.Rows(i).Item( " Modify" )= " Modify.png"

Table6.Rows(i).Item("Modify") = "Modify.png"

Table6.Rows (i).Item( " Name" )= strtxtCust_cp_name

Table6.Rows(i).Item("Name") = strtxtCust_cp_name

Table6.Rows(i).Item( "Ph一个" )= strtxtcust_cp_ph_no

Table6.Rows(i).Item("Phone") = strtxtcust_cp_ph_no

Table6.Rows(i).Item( " Email" )= strtxtCust_cp_email_id

Table6.Rows(i).Item("Email") = strtxtCust_cp_email_id

结束 如果

End If

< font color ="#0000ff"size = 2>结束 Sub

End Sub

推荐答案

亲爱的朋友,

请添加调试并检查弹出窗口中的值是否更新并在web方法中传递在这种情况下,当调用parent.Submit时,它是javascript函数并回发父页面。传递的值在父页面中被重新映射,但在此之前触发了回发。

当你重复这个过程时,它会从前一个尝试中获取数据并显示结果。

尝试从弹出窗口传递不同的值并检查网格是否绑定参数发送通过前一次尝试。

如果是这种情况,那么我们可以给出解决方案来纠正回发和更新。

问候。
Dear Friend,

Please add a debug and check if the values pass from the pop up is updated and passed in the webmethod or not.

In this case, when parent.Submit is called, it is the javascript function and postback the parent page. The passed values are reflcted in the parent page but the postback is triggered before that.

And when you repeat the process, it gets the data from the previous attempt and show you the result.

Try passing different values from popup and check if the grid is bind which the parameters send by the previous attempt.

If this is the case, then we can give the solution to correct the postback and updation.

Regards.


这篇关于如何通过填充webmethod中的数据表并通过其行为调用来填充数据网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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