473,385 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Populating a text box

2
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 1516
kenobewan
4,871 Expert 4TB
Have you tried the OnCheckedChanged event?
Feb 14 '08 #2
JonWB
2
Thank you for your reply. I have tried OnCheckedChanged event with no success. I have been trying to use both the AutoPostBack and javascript in the following ways

if (matReq.Status == MaterialRequisitionStatus.Picking)
{
if (userCanUpdate_)
{
issue.ID = "cbIssue_" + location.ProductCode + "_" + n.ToString();
string box = issue.ID;
issue.AutoPostBack = true;
cellIss.Controls.Add(issue);
txtIssued.Width = Unit.Pixel(50);
txtIssued.ID = "txtIssued_" + location.ProductCode + "_" + n.ToString();
txtIssued.Style.Add("text-align", "right");
cellIssued.Controls.Add(txtIssued);
if (issue.Checked == false)
txtIssued.Text = cellStock.Text;
}
else
cellIssued.Text = "-";
}

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

issue.Attributes.Add("OnCheckedChanged", issue.ClientID + "javascript:_popbox(cbIssue_" + location.ProductCode + "_" + n.ToString() + ", txtIssued_" + location.ProductCode + "_" + 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
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
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...
3
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...
2
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...
3
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...
3
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...
13
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...
4
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: ...
2
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...
2
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();"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.