通过QueryString(AJAX)传递值时出现问题 [英] Problem in Passing value through QueryString (AJAX)

查看:306
本文介绍了通过QueryString(AJAX)传递值时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个三列的网格视图.其中有两个文本框和一个下拉列表.
当我从下拉列表中选择一个值时,我需要在两个文本框中填充从数据库中获取值(不回发).

我用rowdatabound来初始化它....



I have an grid view with three columns. In which two textboxes and one dropdownlist.
While i select an value from dropdown i need to fill the two textboxes with fetching values from Database(WITHOUT POSTBACK).

i used rowdatabound to initialize it....

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            TextBox txtpid = e.Row.FindControl("txt_pid") as TextBox;
            DropDownList txtpname = e.Row.FindControl("txt_pname") as DropDownList; //product name is dropdown
            TextBox txtpsize = e.Row.FindControl("txt_psize") as TextBox;
            txtpname.Attributes.Add("onChange", "javascript: return getEmpName(''" + txtpid.ClientID + "'',''" + txtpname.ClientID + "'',''" + txtpsize.ClientID + "'')");
        }
    }



我的通过Querystring从数据库中获取数据的脚本



My script to fetch data from DB through an Querystring

<script type="text/javascript" language="javascript">

function getEmpName(id,name,size) {

$.ajax({

type : "POST",


url : "Getempname.aspx?prod_name=" + $("#name").attr("value"),//Here am getting value of "name" is Undefined

success : function(reponseText) {
var s = reponseText.toString();
var temp = new Array();
temp = s.split(" ");
document.getElementById(id).value = temp[0];
document.getElementById(size).value = temp[1];
}

});

}

</script>





请帮帮我...
在此先感谢





Please help me out...
Thanks in advance

推荐答案

.ajax({ 类型:"POST", url:"Getempname.aspx?prod_name =" +
.ajax({ type : "POST", url : "Getempname.aspx?prod_name=" +


(#name").attr("value"),//这里获取的是"name"的值是未定义 成功:function(reponseText){ var s = reponseText.toString(); var temp = new Array(); temp = s.split("); document.getElementById(id).value = temp [0]; document.getElementById(size).value = temp [1]; } }); } < /script >
("#name").attr("value"),//Here am getting value of "name" is Undefined success : function(reponseText) { var s = reponseText.toString(); var temp = new Array(); temp = s.split(" "); document.getElementById(id).value = temp[0]; document.getElementById(size).value = temp[1]; } }); } </script>





请帮帮我...
预先感谢





Please help me out...
Thanks in advance


好,如果您的问题失去了选择,您的代码是否每次都绑定该下拉列表?那将重置选择.对于其余部分,如果您查看源代码,那么使用的ID是控件的正确ID吗?
OK, if your issue is losing your selection, does your code bind that drop down every time ? That would reset the selection. For the rest, if you view the source, is the ID being used the correct ID of the control ?


这篇关于通过QueryString(AJAX)传递值时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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