This is the code i am using bind the database values and display the values in html table.
public void load_builder() { SqlConnection con = new SqlConnection(constring); con.Open(); string sql = "select category,category_code,created_date from category"; SqlCommand cmd = new SqlCommand(sql, con); SqlDataReader dr; dr = cmd.ExecuteReader(); //sb.Append(""); while (dr.Read()) {
sb.Append("
"); sb.Append("
"); sb.Append("
" + dr[0].ToString() + "
"); sb.Append("
" + dr[1].ToString() + "
"); sb.Append("
"); }
this is the html table grid structure.
select
Category Name
Category Code
after clicking this select option i want display the particular row values into particular text fields for update purpose..that means (cateory name and categorycode )data want to display in text fields.
for this purpose i am using the javascript function called loaddata
loaddata code:
but i am not able to get the particular row values to text box after clicking the select option..
Help me for this......
Advanec thx..
7 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
in gird i have select option and two text fields data. that select option will help to pass the values from grid to textfileds for modification purpose.
in a grid row, after clicking the select option category code value pass to two text fields. category name value not passing to text fields.
so i want to pass two values to each textboxes according to fields.
(while i am passing values grid to textboxes using javascript) two fields filled with category code data only. category name value is not passing from grid) but i want to pass both value to text boxes)
Jignesh TrivediPosted Apr 25, 2012, 5:44 AM
Please try...
sb.Append("
also you can use tag for same.
hope this help.
sudharsan sPosted Apr 25, 2012, 8:46 AM
i have tow textfields....
category code and category name...
in gird i have select option and two text fields data. that select option will help to pass the values from grid to textfileds for modification purpose.
in a grid row, after clicking the select option category code value pass to two text fields. category name value not passing to text fields.
so i want to pass two values to each textboxes according to fields.
(while i am passing values grid to textboxes using javascript) two fields filled with category code data only. category name value is not passing from grid) but i want to pass both value to text boxes)
help me
advanx thx
Jignesh TrivediPosted Apr 25, 2012, 8:31 AM
Actually I am not getting your point.
As per my understanding
If you click on category code filed then only category code fill textbox.
Is it correct??
sudharsan sPosted Apr 25, 2012, 8:22 AM
Thank you for ur coding which was posted by u before....it s working.
i am able to pass the values grid table to textfields...
i have two text fields... (category code, category name)
when i am click select the category code data passed to two filelds....
i want particular data in particular fields..
Help me..
Advanx thx.
SenthilkumarPosted Apr 25, 2012, 5:24 AM
sudharsan sPosted Apr 25, 2012, 5:22 AM
sb.Append("
sb.Append("
sb.Append("
sb.Append("
sb.Append("
javascript function
function loaddata(val) {
document.getElementById("<%=txtcategory.ClientID%>").value = val;
document.getElementById("<%=txtxtCategoryCode.ClientID%>").value = val;
}
but still i have same problem... after clicking select it s not working. Shall i send the full code..
Advance thx ..!
SenthilkumarPosted Apr 25, 2012, 2:01 AM
Do not use the label. Use the Span tag. write the onclick event on top of that.
sb.Append("
Here you are passing the actual value and not the id of the control.
function loaddata(val) {
document.getElementById("<%=txtxtCategoryCode.ClientID%>").value = val;
document.getElementById("<%=txtcategory.ClientID%>").value = val;
}
Try this and let me know.