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 Answers
Know the answer? Post it. Somebody with the same question will find it here.
sudharsan s110 reputationPosted Apr 25, 2012, 4:46 AM EDT
0
Thanks for reply,,,
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)
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 25, 2012, 1:44 AM EDT
Please try...
sb.Append("
also you can use tag for same.
hope this help.
SenthilkumarRank #387 · 6.5K reputationPosted Apr 24, 2012, 10:01 PM EDT
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.
sudharsan s110 reputationPosted Apr 25, 2012, 1:22 AM EDT
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 ..!
SenthilkumarRank #387 · 6.5K reputationPosted Apr 25, 2012, 1:24 AM EDT
sudharsan s110 reputationPosted Apr 25, 2012, 4:22 AM EDT
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.
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 25, 2012, 4:31 AM EDT
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 s110 reputationPosted Apr 25, 2012, 4:46 AM EDT
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