Click here to Skip to main content
15,905,682 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

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 + "')");
        }
    }


My script to fetch data from DB through an Querystring

XML
<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
Posted
Updated 5-Jul-11 21:50pm
v4
Comments
[no name] 6-Jul-11 3:28am    
Edited for Code Block.
J.Karthick 6-Jul-11 3:44am    
Pardon me...
[no name] 6-Jul-11 3:47am    
Ok.
J.Karthick 6-Jul-11 3:49am    
but solution for my issue?
J.Karthick 6-Jul-11 3:48am    
Even i tried passing dropdownlist.Selecteditem.text am getting "-Select-" which was in my Zeroth index of my dropdown

1 solution

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 ?
 
Share this answer
 
Comments
J.Karthick 6-Jul-11 4:22am    
ya... i changed those id... but how to get my selection item from the dropdown...

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