| | |
databound controls
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
Hi ,
I need to create a page that has databound controls . eg.
Say i have a row with the following columns
1. TrackKey VARCHAR(50)
2. State VARCHAR(50)
3. Reason VARCHAR(50)
4. DateChanged DATETIME
------------------------------------------------------------
Now for each row in the table, the controls should be like this
1. TrackKey - Label
2. State - dropdownlist
3. Reason textbox
4. DateChanged - 3 dropdownlists [years, months , days]
---------------------------------------------------------------
I am able to dynamically load these controls, but due to postback i cannot save the information that changed.
can anyone give me some advice on how to change this ?
here is my code for loading:
PLEASE HELP !!!!!!!
I need to create a page that has databound controls . eg.
Say i have a row with the following columns
1. TrackKey VARCHAR(50)
2. State VARCHAR(50)
3. Reason VARCHAR(50)
4. DateChanged DATETIME
------------------------------------------------------------
Now for each row in the table, the controls should be like this
1. TrackKey - Label
2. State - dropdownlist
3. Reason textbox
4. DateChanged - 3 dropdownlists [years, months , days]
---------------------------------------------------------------
I am able to dynamically load these controls, but due to postback i cannot save the information that changed.
can anyone give me some advice on how to change this ?
here is my code for loading:
ASP.NET Syntax (Toggle Plain Text)
void GenerateList() { // This method will generate a table for editing states // Dataset for storing values DataSet setGetTrackings = new DataSet(); // In the grid - the controls Label TrackKey = new Label(); DropDownList SetState = new DropDownList(); TextBox reason = new TextBox(); DropDownList Days = new DropDownList(); DropDownList Months = new DropDownList(); DropDownList Years = new DropDownList(); HtmlTableCell htmlCell = null; HtmlTableRow htmlRow = null; HandleStates entry = new HandleStates(); // finally we will count the rows for inserting int rowcount = 2; int IndexCount = 0; //Set the tables. if (setGetTrackings != null && setGetTrackings.Tables.Count > 0) { foreach (DataRow row in setGetTrackings.Tables[0].Rows) { // Create the controls. TrackKey = new Label(); SetState = new DropDownList(); htmlCell = null; htmlRow = null; reason = new TextBox(); Days = new DropDownList(); Months = new DropDownList(); Years = new DropDownList(); #region Populate Controls // Set the values TrackKey.Text = row[0].ToString(); SetState.Items.Add(row[7].ToString()); reason.TextMode = TextBoxMode.MultiLine; // Add more Items To The DropDown SetState.Items.Add("--New State--"); SetState.Items.Add("Visiting x Branch"); SetState.Items.Add("Visiting y Branch"); SetState.Items.Add("Received"); SetState.Items.Add("Ready To Go"); SetState.Items.Add("Not Ready To Go"); SetState.Items.Add("Submitted"); SetState.Items.Add("Acquired"); SetState.Items.Add("Denied"); // Adding attributes to the dropdown int IDDay = 10000000 + rowcount; int IDMonth = 11000000 + rowcount; int IDYear = 12000000 + rowcount; int IDTetbox = 13000000 + rowcount; SetState.ID = rowcount.ToString(); reason.ID = IDTetbox.ToString(); Days.ID = IDDay.ToString(); Months.ID = IDMonth.ToString(); Years.ID = IDYear.ToString(); int D1 = 1; int D2 = 32; while (D1 < D2) { Days.Items.Add(D1.ToString()); D1++; } int M1 = 1; int M2 = 13; while (M1 < M2) { Months.Items.Add(M1.ToString()); M1++; } string CurrentYear = string.Format("{0:yyyy}", DateTime.Now); int Y1 = int.Parse(CurrentYear); int Y2 = int.Parse(CurrentYear) + 3; while (Y1 < Y2) { Years.Items.Add(Y1.ToString()); Y1++; } #endregion // Create the row htmlRow = new HtmlTableRow(); // Populate the cells #region Populate the main cells // Create the track key cell. htmlCell = new HtmlTableCell(); htmlCell.Attributes.Add("class", "UserManageField"); htmlCell.Controls.Add(TrackKey); htmlRow.Cells.Add(htmlCell); // Create the SetState cell. htmlCell = new HtmlTableCell(); //htmlCell.Attributes.Add("class", "FormtextBox"); htmlCell.Controls.Add(SetState); htmlRow.Cells.Add(htmlCell); #endregion tblTrackings.Rows.Add(htmlRow); rowcount++; // New Row To insert hidden fields htmlRow = new HtmlTableRow(); #region Blank cells // adding seven blank columns htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); #endregion // Add some attributes reason.Style.Add("visibility", "hidden"); Days.Style.Add("visibility", "hidden"); Months.Style.Add("visibility", "hidden"); Years.Style.Add("visibility", "hidden"); // Create the date cell. htmlCell = new HtmlTableCell(); reason.Text = "This is a hidden textbox"; htmlCell.Controls.Add(reason); htmlCell.Controls.Add(Days); Days.Text = "1"; htmlCell.Controls.Add(Months); Months.Text = "1"; htmlCell.Controls.Add(Years); Years.Text = "2009"; htmlRow.Cells.Add(htmlCell); tblTrackings.Rows.Add(htmlRow); rowcount++; // New Row To insert hidden fields htmlRow = new HtmlTableRow(); #region Blank cells // adding seven blank columns htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); htmlCell = new HtmlTableCell(); htmlCell.InnerText = " "; htmlRow.Cells.Add(htmlCell); #endregion // Create the date cell. htmlCell = new HtmlTableCell(); htmlCell.Controls.Add(Days); Days.Text = "1"; htmlCell.Controls.Add(Months); Months.Text = "1"; htmlCell.Controls.Add(Years); Years.Text = "2009"; htmlRow.Cells.Add(htmlCell); tblTrackings.Rows.Add(htmlRow); rowcount++; #region Script SetState.SelectedIndex = 0; Days.SelectedIndex = 0; Months.SelectedIndex = 0; Years.SelectedIndex = 0; SetState.Attributes.Add("onChange", "SetVisibility();"); StringBuilder scriptBuilder = new StringBuilder(); scriptBuilder.Append("<script type='text/javascript' language='javascript'>"); scriptBuilder.Append("function SetVisibility()"); scriptBuilder.Append("{"); scriptBuilder.AppendFormat("var ddSetstate = document.getElementById('{0}'); ", SetState.ClientID); scriptBuilder.Append("var ddSetstate_selectedelement = ddSetstate.options[ddSetstate.selectedIndex].text; "); scriptBuilder.AppendFormat("var ReasonTextBox = document.getElementById('{0}'); ", reason.ClientID); scriptBuilder.AppendFormat("var dayCBO = document.getElementById('{0}'); ", Days.ClientID); scriptBuilder.AppendFormat("var monthCBO = document.getElementById('{0}'); ", Months.ClientID); scriptBuilder.AppendFormat("var yearCBO = document.getElementById('{0}'); ", Years.ClientID); scriptBuilder.Append("if (ddSetstate_selectedelement == 'Not Ready To Go') "); scriptBuilder.Append(" { "); scriptBuilder.Append(" ReasonTextBox.style.visibility = ''; "); scriptBuilder.Append(" dayCBO.style.visibility = 'hidden'; "); scriptBuilder.Append(" monthCBO.style.visibility = 'hidden'; "); scriptBuilder.Append(" yearCBO.style.visibility = 'hidden'; "); scriptBuilder.Append(" } "); scriptBuilder.Append("else if (ddSetstate_selectedelement == 'Successfully Submitted') "); scriptBuilder.Append(" { "); scriptBuilder.Append(" dayCBO.style.visibility = ''; "); scriptBuilder.Append(" monthCBO.style.visibility = ''; "); scriptBuilder.Append(" yearCBO.style.visibility = ''; "); scriptBuilder.Append(" ReasonTextBox.style.visibility = 'hidden'; "); scriptBuilder.Append(" } "); scriptBuilder.Append(" else "); scriptBuilder.Append(" { "); scriptBuilder.Append(" dayCBO.style.visibility = 'hidden'; "); scriptBuilder.Append(" monthCBO.style.visibility = 'hidden'; "); scriptBuilder.Append(" yearCBO.style.visibility = 'hidden'; "); scriptBuilder.Append(" ReasonTextBox.style.visibility = 'hidden'; "); scriptBuilder.Append(" } "); scriptBuilder.Append("JSetStates();"); scriptBuilder.Append(" } "); scriptBuilder.Append("</script>"); base.ClientScript.RegisterClientScriptBlock(typeof(void), "Myscripts", scriptBuilder.ToString()); #endregion } }
PLEASE HELP !!!!!!!
Delphi & C# programmer deluxe...
![]() |
Similar Threads
- problem in making listview (Visual Basic 4 / 5 / 6)
- Populate dropdownlist in formview (ASP.NET)
- passing data from form1 to form2 (Visual Basic 4 / 5 / 6)
- Using activex controls in visual basic (Visual Basic 4 / 5 / 6)
- Is is possible to use windows common controls in java (Java)
- Adding controls into a ListView (Visual Basic 4 / 5 / 6)
- Populating & Retrieving Data in a listbox : ASP.NET (w/ VB.NET) (ASP.NET)
- ASP.NET controls in Office 2003 style? (ASP.NET)
- Drag and Drop controls? (Visual Basic 4 / 5 / 6)
Other Threads in the ASP.NET Forum
- Previous Thread: Populating a TreeView
- Next Thread: Urgent help requried with connection string
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers






