473,610 Members | 2,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populating a text box

2 New Member
Hi,

I am very new to .Net and have recently taken over someone else’s project. I am developing an asp webpage using C#.

I have an asp:table that is populated using data from a database. However, there is also a column that contains checkboxes and a column that contains text boxes like so:

Location | Stock | Issue (checkbox column) | Issued (textbox column)

I want the user to click a checkbox and the value of the ‘Stock’ column for that row is then entered into the textbox of that row.

I have already populated the table with data and the user controls, I am only struggling with the event.

My code is shown below:

Expand|Select|Wrap|Line Numbers
  1. TableRow row = new TableRow();
  2.                 TableCell cellLoc = new TableCell();
  3.                 TableCell cellStock = new TableCell();
  4.                 TableCell cellIss = new TableCell();
  5.                 TableCell cellIssued = new TableCell();
  6.  
  7.                 cellLoc.Width = Unit.Pixel(75);
  8.                 cellStock.Width = Unit.Pixel(75);
  9.                 cellIss.Width = Unit.Pixel(75);
  10.                 cellIssued.Width = Unit.Pixel(75);
  11.  
  12.                 TextBox txtIssued = new TextBox();
  13.                 CheckBox issue = new CheckBox();
  14.  
  15.                 cellLoc.HorizontalAlign = HorizontalAlign.Left;
  16.                 cellLoc.Text = location.Aisle + " " + location.Bay + " " + location.Level;
  17.  
  18.                 if (matReq.Status >= MaterialRequisitionStatus.Picking)
  19.                 {
  20.                     cellStock.Text = location.QtyRequired.ToString();
  21.  
  22.                     if (matReq.Status == MaterialRequisitionStatus.Picking)
  23.                     {
  24.                         if (userCanUpdate_)
  25.                         {
  26.                             issue.ID = "cbIssue_" + location.ProductCode + "_" + n.ToString();
  27.                             string box = issue.ID;
  28.                             issue.AutoPostBack = true;
  29.                             cellIss.Controls.Add(issue);
  30.                             txtIssued.Width = Unit.Pixel(50);
  31.                             txtIssued.ID = "txtIssued_" + location.ProductCode + "_" + n.ToString();
  32.                             txtIssued.Style.Add("text-align", "right");
  33.                             cellIssued.Controls.Add(txtIssued);
  34.  
  35.                         }
  36.                         else
  37.                             cellIssued.Text = "-";
  38.                     }
  39.                     else
  40.                         cellIssued.Text = location.QtyPicked.ToString();
  41.                 }
  42.                 else
  43.                 {
  44.                     cellStock.Text = location.Stock.ToString();
  45.                     cellIssued.Text = "-";
  46.                 }
  47.  
  48.                 row.Cells.Add(cellLoc);
  49.                 row.Cells.Add(cellStock);
  50.                 row.Cells.Add(cellIss);
  51.                 row.Cells.Add(cellIssued);
  52.  
  53.                 tblStock.Rows.Add(row);
This is my first post, so I hope I have given enough information for you to understand what I am attempting to do.

Thanks in advance,

Jonathan.
Feb 14 '08 #1
2 1524
kenobewan
4,871 Recognized Expert Specialist
Have you tried the OnCheckedChange d event?
Feb 14 '08 #2
JonWB
2 New Member
Thank you for your reply. I have tried OnCheckedChange d event with no success. I have been trying to use both the AutoPostBack and javascript in the following ways

if (matReq.Status == MaterialRequisi tionStatus.Pick ing)
{
if (userCanUpdate_ )
{
issue.ID = "cbIssue_" + location.Produc tCode + "_" + n.ToString();
string box = issue.ID;
issue.AutoPostB ack = true;
cellIss.Control s.Add(issue);
txtIssued.Width = Unit.Pixel(50);
txtIssued.ID = "txtIssued_ " + location.Produc tCode + "_" + n.ToString();
txtIssued.Style .Add("text-align", "right");
cellIssued.Cont rols.Add(txtIss ued);
if (issue.Checked == false)
txtIssued.Text = cellStock.Text;
}
else
cellIssued.Text = "-";
}

and using javascript I replaced the if (issue.Checked == false) statement with:

issue.Attribute s.Add("OnChecke dChanged", issue.ClientID + "javascript:_po pbox(cbIssue_" + location.Produc tCode + "_" + n.ToString() + ", txtIssued_" + location.Produc tCode + "_" + n.ToString() + ", " + cellStock.Text + ");");

with javascript:

function _popbox(check, txt, val)
{
if (check.checked = true)
{
txt.Text = val;
}
}

I haven’t been able to get either method to work. Do you think that either of these ways are possible?

Thanks,

Jonathan.
Feb 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
4070
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
0
1339
by: Bill Brinkworth | last post by:
I want the user to type in part of a word, and I want to return all words from an Access word table that contains specified letters. If they were to type "fe??", it should return all words in the dictionary that are 4 letters and begin with "fe" into a listbox. I am having difficulting searching for all words and taking all those words and populating a listbox. Can you help? Here's what I have: CLASS - Public Property word() As String...
3
5878
by: Neil Guyette | last post by:
Hello, Everyone, I'm trying to find information on how to populate a combo box using a SqlDataReader. I want to be able to set the value of the combo's value property different then the combo's text property (what the user will see). Is this possible with a SqlDataReader? Thanks
2
2403
by: Chris Barrow | last post by:
Hi everyone, Does anyone know if there is a problem populating a system.web.ui.htmlcontrols.htmlinputtext control when the control's type is set to "password?" I am attempting to retreive a member's record from a database and populate the control with the member's password. Unfortunately, if the control declared on the .aspx side is as follows: <input type="password" id="txtPassword" runat="server"/>
3
1567
by: luna | last post by:
theres no errors in my code - but it does nothing at all - its supposed to be populating text boxes!! any ideas ? (im am pretty new to all this) If Not Page.IsPostBack Then Dim search As String Dim strConn As String = "server=Gringotts;uid=sa;pwd=password;database=database"
3
6032
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is "LabLocation_ID". With an existing lab, they then need to add the members for that lab. So, what I am trying to do is the following. With the FormView of the Lab open, the user will click a button to open a FormView (InsertMode) and add a new...
13
3533
by: Mary | last post by:
I'll pulling my hair out on this one and would be so appreciative of any help. I am creating a data entry form to enter results of a student survey. There are 40 questions on the survey. The first 7 have to do with respondent information like grade, class and age. I have those in a table with a PK of RespondentId, which is autonumbered. Questions 8-40 all have the same format. For these questions I have a table set up with the...
4
20056
by: prosad | last post by:
hello, Just solved a problem using Javascript onclick, can click on any cell in a dynamic table and it will pass the innerText object value to my form text field. parts of code given below: <script type="text/javascript"> function select_cell(obj) { document.getElementById('complaint').value = obj.innerText; document.getElementById('selected_form'); }
2
3265
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once selecting from the combo box, I have all the combo boxes, using afterupdate, populating their respective list boxes. These text boxes are directly correlated to the combo box selection using SQL. Here is an example from the afterupdate event in the...
2
1954
by: Alexio | last post by:
Sample code snippet - <td align="right">Check Amount:&nbsp;</td> (1) <td><input type="text" name="CHK_input_1" size="19"style="text-align:right" onkeyup="calcCB();" onBlur="currency(this); calcCB();" tabindex="26"> (2) <input type="hidden" name="OBKey__53_1" id="kw_check_amount" > For various database reasons, I need to be able to populate a hidden field to be used as a keyword in our system based on the first...
0
8097
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8238
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8411
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7036
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6071
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5526
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4040
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.