Populating Values from database onto html controls

saithin

New Member
I have an asp.net page with a textbox and three dropdown lists of HTML controls and two buttons called EDIT and NEW.When the user click on EDIT,should be able to edit System Name and when the user click on NEW, can create new system. How can I pull the data from database based on the system Id and populate the values onto the controls,when user clicks on EDIT button. Can anyone suggest me in doing this? Thanks.ASPX Page:\[code\] <div class="FormSection"> <div class="FormSectionHeader"> System </div> <div class="FormSectionContent"> <table width="100%" cellpadding="3px" cellspacing="0"> <colgroup> <col width="115px" /> <col width="*" /> </colgroup> <tr> <th><label>System Name</label></th> <td><input id="tbsystemName" type="text" style="width:100%" value="http://stackoverflow.com/questions/15476679/System Name Here" /></td> </tr> <tr> <th><label>Packet Type</label></th> <td><select id="ddlselectedPacket Type" style="width:100%"><option value="http://stackoverflow.com/questions/15476679/1">- Please select a Packet type -</option><option value="http://stackoverflow.com/questions/15476679/T">T</option><option value="http://stackoverflow.com/questions/15476679/H">H</option></select></td> </tr> <tr> <th><label>Version Type</label></th> <td><select id="ddlselectedVersionType" style="width:100%"><option value="http://stackoverflow.com/questions/15476679/2">- Please select a Version type -</option><option value="http://stackoverflow.com/questions/15476679/Full">Full</option><option value="http://stackoverflow.com/questions/15476679/Partial">Partial</option></select></td> </tr> <tr> <th><label>System Model</label></th> <td><select id="ddlselectedSystemModel" style="width:100%"><option value="http://stackoverflow.com/questions/15476679/3">- Please select a system Model -</option><option value="http://stackoverflow.com/questions/15476679/Single">Single</option><option value="http://stackoverflow.com/questions/15476679/Multiple">Multiple</option></select></td> </tr> </table> </div> </div>\[/code\]ASPX.CS Page:\[code\]public partial class ViewSystem : System.Web.UI.Page{ public void Page_Init(object o, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["Mode"] != null) { string mode = Request.QueryString["Mode"].ToString(); if (mode == "New") { hdnMode.Value = "http://stackoverflow.com/questions/15476679/New"; } else if (mode == "Edit") { if (Request.QueryString["SystemId"] != null) { string SystemId = Request.QueryString["SystemId"].ToString(); //hdnMode.Value = "http://stackoverflow.com/questions/15476679/New"; //hdnSystemId.Value = http://stackoverflow.com/questions/15476679/SystemId; } } } } }\[/code\]Jquery :\[code\]function btnNewSystem() {var obj = new Object();// Show the child formshowModalDialog('/_system/ViewSystem.aspx?mode=New&randval=' + Math.random(), obj, 'dialogHeight: 800px; dialogWidth: 900px;');\[/code\]}\[code\]function btnEditSystem() {var obj = new Object();// Store the hidden value & text fields into variablesvar hdnSelectedValue = http://stackoverflow.com/questions/15476679/document.getElementById('hdnSelectedValue');var hdnSelectedText = document.getElementById('hdnSelectedText');// Show the child formshowModalDialog('/_system/ViewSystem.aspx?mode=Edit&SystemId=' + hdnSelectedValue.value + '&randval=' + Math.random(), obj, 'dialogHeight: 800px; dialogWidth: 900px;');\[/code\]}
 
Back
Top