how can i use variable in findcontrol? - find

first,i add gridview my page..and i creat textbox dynamically for each cell..
textboxarray[idm].ID = idm.ToString();
idm is a variable which contains textbox id.
when i want to control by if control
if (((TextBox)(GridView2.Rows[str].Cells[stn].FindControl(idm.ToString()))).Text != null)
{
matris[i, j] = Convert.ToInt32(GridView2.Rows[str].Cells[stn].Text);
}
occur an error
Object reference not set to an instance of an object.
how can id do it?

Related

How to update value of a cell that have a Hyperlink by Smartsheeet API C# SDK?

We have to update value of a smartsheet Cell. This Cell contains Hyperlink to a different sheet. Hyperlink URL is assigned. We want to update this cell value by Smartsheet API C# SDK.
If I'm understanding your scenario correctly, a cell in your sheet contains a hyperlink to another Smartsheet sheet (as described here), and you want to update that cell value to be a hyperlink that points to a different sheet in Smartsheet. The following code uses the Smartsheet C# SDK to accomplish that.
// Replace the second parameter here with your API Access Token
System.Environment.SetEnvironmentVariable("SMARTSHEET_ACCESS_TOKEN", "replace-this-string-with-your-API-access-token");
SmartsheetClient smartsheet = new SmartsheetBuilder().Build();
// Specify updated cell value (hyperlink to another sheet)
var cellToUpdate = new Cell
{
ColumnId = 6101753539127172, // ID of the column that contains the cell you're updating
Value = "text-value-for-hyperlink", // text value of hyperlink to display in the cell -- typically set to the target Sheet's name
Hyperlink = new Hyperlink
{
SheetId = 7501762300012420 // ID of the sheet that the hyperlink will point to
}
};
// Identify row and add updated cell object to it
var rowToUpdate = new Row
{
Id = 4324392993613700, // ID of the row that contains the cell you're updating
Cells = new Cell[] { cellToUpdate }
};
// Issue the 'update row(s)' request
IList<Row> updatedRow = smartsheet.SheetResources.RowResources.UpdateRows(
3932034054809476, // ID of the sheet that you're updating
new Row[] { rowToUpdate }
);
Hopefully this is helpful. If I'm not understanding your scenario correctly, please comment on this answer to elaborate further about your scenario.
** UPDATE - replacing the sheet hyperlink with another type of value **
Please note, if you want to remove the sheet hyperlink from the cell and replace it with another value, you should specify an empty Hyperlink object in the request, as shown in the following code.
// Specify updated cell value (just a text value -- i.e., no longer a sheet hyperlink)
var cellToUpdate = new Cell
{
ColumnId = 6101753539127172, // ID of the column that contains the cell you're updating
Value = "new-cell-value",
Hyperlink = new Hyperlink()
};

SAPUI5 List Item context binding, get the next path

I have a table of list items (questions) and I want to be able to re-arrange them. See screenshot.
Currently, on the button down press, I can get the current binding context and I am getting that sequence property (001). What I want to be able to do is also be able to get the path of the next list items binding context (002 in this case).
Current code...
// Move Question Down
onQuestionMoveDown: function (oEvent) {
// Get binding context
var source = oEvent.getSource().getBindingContext("view");
var path = source.getPath();
var object = source.getModel().getProperty(path);
var currentQuestionSequence = object.Sequence;
MessageToast.show("Current # " + currentQuestionSequence);
}
Then once I have that I can sort my updates logic.
A possible solution could be that you have an order value on your model and you update that order when the user clicks on the button.
If the list is sorted by that value you will achieve what you're looking for.
The items should be bound to the table via list binding, and so the data set would be an Array, the path for each line will be like ".../itemSet/0, .../itemSet/1, ...". So possible solution could be:
function getNextItem(oItem){
var oContext = oItem.getBindingContext("view"), // assumpe the model name is view
sPath = oContext.getPath(),
sSetPath = sPath.substr(0, sPath.lastIndexOf("/")),
iMaxLen = oContext.getProperty(sSetPath).length,
iCurIndex = parseInt(sPath.substr(sPath.lastIndexOf("/")+1));
// If it's already reach to be bottom, return undefined
return iCurIndex < iMaxLen -1 ? oContext.getProperty(sSetPath + "/" + ++iCurIndex) : undefined;
}
Regards,
Marvin

Set object properties after setting the object

I've created a class with various properties in VB6.
The properties are
PiccoId
OrderId
UserId
StockCode
Quantity
At the top of the class I have declared 2 instances of classes I'm using.
Dim stkLine As CSOPSLine ' This is the class where the properties are declared and read
Private SOPSLines As cSLine ' This class creates the new objects and sets the property values
When the user enters the order number on a handheld barcode scanner, I'm creating an object to associate with this particular scanner like so:
Set SOPSLines = New cSLine
Set SOPSLines = getSOPSLine(ID, sOrder, "", "", 0)
In the next stage of the process, the user needs to enter their user ID so it can be seen which user scanned in the item.
I need to update the property of this same object, but I'm not sure how - Currently I am trying to do it within my getSOPSLine function, like this:
Dim line As New CSOPSLine
Dim bFound As Boolean
bFound = False
For Each line In SOPSLines.Items
If line.PiccoId = ID Then
line.OrderId = OrderId
line.Quantity = Qty
line.StockCode = stock
line.UserId = UserId
Set getSOPSLine = line
bFound = True
Exit For
End If
Next
If bFound = False Then
Set line = SOPSLines.Add(ID, OrderId, UserId, stock, Qty)
Set getSOPSLine = line
End If
Set line = Nothing
However, as I'm not storing sOrder at class level (Due to the fact multiple users can be using barcode scanners, the order ID can't be kept at class level as other users will just overwrite it),
I'm not sure how once I've got the next variable (In this case, userID, and the other variables after this stage) I can update the same object as I've just created.
I've tried to do something like
Set stkLine = getSOPSLine(ID, stkLine.OrderId, pUser, "", 0)
but it errors saying
object or with block variable has not been set
How can I update the properties of stkLine without constantly creating new objects?
EDIT
To clarify:
When the application receives data from the handheld barcode scanner, a select case is entered, with one case for each of the variables being entered (E.g. Order ID, user ID, stock code etc.)
The first case sets the order ID.
The code here is
Case FRAME_ORDER_SELECTION
On Error Resume Next
Dim sOrder As Long
sOrder = Picco.GetData(ID, 50)
If sOrder = 0 Then
Call Picco.Send(ID, FRAME_ORDER_SELECTION)
Exit Sub
Else
With Picco
Call .ClearForm(ID)
Call .Text(ID, LINE_1, "===== User ID =====")
Call .Text(ID, LINE_2, "")
Call .NewField(ID, 60, 5, FLD_LINE + SND_ENTER)
Call .Send(ID, FRAME_LINE_ADD)
Set SOPSLines = New cSLine
Set SOPSLines = getSOPSLine(ID, sOrder, "", "", 0)
End With
End If
frameid = FRAME_LINE_ADD
m_iLastFrameId = FRAME_ORDER_SELECTION
On Error GoTo Picco_DataArrived_Err
This is where the object is created.
The next case is after the user enters their user ID into the scanner.
Case FRAME_LINE_ADD
On Error Resume Next
Dim pUser As String
pUser = ""
pUser = Picco.GetData(ID, 60)
If pUser = "" Then
Exit Sub
End If
On Error GoTo Picco_DataArrived_Err
With Picco
Call .ClearForm(ID)
Call .Text(ID, LINE_1, "===== Add Line =====")
Call .Text(ID, LINE_2, "")
Call .Text(ID, LINE_7, "Scan or type code")
Call .NewField(ID, FIELD_POS, 18, FLD_LINE + FLD_READER + SND_ENTER)
Call .Send(ID, FRAME_LINE_QTY)
End With
Set stkLine = getSOPSLine(ID, stkLine.OrderId, pUser, "", 0)
frameid = FRAME_LINE_QTY
m_iLastFrameId = FRAME_LINE_ADD
Then there will be 2 or 3 more cases when populating the rest of the required values.
What I need to do, is in the second case (And all other following cases) update the properties of the object created in the first case.
I'm using the getSOPSLine function as this gets the object with the matching barcode scanner ID (As multiple users may be accessing different orders, they need to be kept separate in this way), but I'm not sure how to update the object where the scanner ID matches.
When you call getSOPSLine in each Case, enter some temporary values for the variables that you're not setting.
Example;
In the UserID case: stkLine = getSOPSLine(ID, 0, pUser, "", 0)
Then, in the getSOPSLine() function, change it so that instead of setting the values automatically, it instead only updates them if they don't equal 0, or "", or whichever temporary variables you use.
That way you're updating the same object, but aren't storing data that may get overwritten.
I'm not sure what you're confused about; I think that you must have some misunderstanding of what objects, variables, and properties are that is preventing you from asking this in a way that I understand. I'm not sure how your code lines up with your questions. But I'll give this a shot:
Private SOPSLines As cSLine
Set SOPSLines = New cSLine
Set SOPSLines = getSOPSLine(ID, sOrder, "", "", 0)
This declares a class-level variable, that can hold a cSLine object. That seems reasonable. Then you create a new instance of cSLine to put in that variable. But I don't know why, because you then point the variable to a different instance entirely, which is the instance returned from your getSOPSLine function. That middle line doesn't seem to be doing anything, and I'm not sure what you're trying to do with it.
I've tried to do something like
Set stkLine = getSOPSLine(ID, stkLine.OrderId, pUser, "", 0)
but it errors saying
object or with block variable has not been set
Well, then it sounds like stkLine isn't set to an object. I don't see any code that's trying to set stkLine other than that line. So when you try to get stkLine.OrderId, there isn't an object to get the OrderID property of, so it gives you an error.
I need to update the property of this same object, but I'm not sure how
Well, if there's an object you care about, you probably have it in a variable somewhere. You use variable.property = value syntax to assign value to the property of the object currently stored in variable.
But again, I'm not sure where your confusion is, since you're clearly assigning properties of objects in your code already.
If you're not understanding how objects work in VB, I'd recommend reading through the Working with Objects chapter of the documentation.
And if your confusion lies elsewhere, perhaps you could put together a more specific question about what you're trying to do?

Can't autopopulate fields when adding new record - "You can't assign value to this object"

I am trying to make a form where I would enter new data. I am trying to make a combobox which would when I press selected record autofill data in form with known data. So I have Owner [Vlasnik] table and I am able to autofill info about owner but I am not able to change ID_VU which is unique key for each owner.
Private Sub cboID_VU2_Change()
Me.[Vlasnik.ID_VU].Value = Me.cboID_VU2.Column(0)
Me.[Naziv tvrtke].Value = Me.cboID_VU2.Column(1)
Me.[Ime korisnika].Value = Me.cboID_VU2.Column(2)
Me.[Prezime korisnika].Value = Me.cboID_VU2.Column(3)
Me.[Adresa korisnika].Value = Me.cboID_VU2.Column(4)
Me.[Telefon].Value = Me.cboID_VU2.Column(5)
Me.Mail.Value = Me.cboID_VU2.Column(6)
End Sub
Control source of comobox is empty and this is rowsource :
SELECT Vlasnik.ID_VU, Vlasnik.[Naziv tvrtke], Vlasnik.[Ime korisnika], Vlasnik.[Prezime korisnika], Vlasnik.[Adresa korisnika], Vlasnik.Telefon, Vlasnik.Mail FROM Vlasnik ORDER BY Vlasnik.[Prezime korisnika];
When I try to run a code I am getting error on line
Me.[Vlasnik.ID_VU].Value = Me.cboID_VU2.Column(0)
with message "You can't assign value to this object"
I think problem is that Vlasnik.ID_VU is set as autonumber

as3 - loop over all text fields?

I have a form in as3 flash with textfields and radio buttons with their "instance name" all set consecutively such as:
field_1
field_2
field_3
...etc
Is there an easy way in AS3 code to loop over all those fields and get their values in an array? Ideally I'd like a simply loop to get the values (so I can add in a simple popup if a value is missing) and then with the filled array simply post it using URLRequest.
Thanks!
If you want a way that's a little less work and more maintainable (if the amount of text can change in the future or you need to reuse the code on other forms or don't want to bother with instance names), then you could do something like the code below.
Keep in mind this assumes all your text fields are children of the same parent and is in the scope of that parent (so on a frame in the timeline that holds all your text fields)
function validateTextFields(){
var tmpTf:TextField;
var i:int = numChildren;
while(i--){ //iterate through all the display objects on this timeline
tmpTf = getChildAt(i) as TextField;
if(tmpTf){
//now that you have the textfield, you can check for an appropriate value, or send the value to a server, or store it in an array etc.
//check if the value is blank, if so set the background to red
if(tmpTf.text == ""){
tmpTf.background = true;
tmpTf.backgroundColor = 0xFF0000;
}else{
tmpTf.background = false;
}
}
}
}
It sounds like you want to use a for statement. I've also used a multi-dimensional array to store the instance names, and the text that they contain. I like to use the variable _path to define the scope of my code.
var _path = this;
var text_ar:Array = new Array(['instance_1',''],['instance_2',''],['instance_3','']); //instance name, instance text.
for(var i=0; i<ar.length; i++)
{
text_ar[i][1] = _path[text_ar[i][0]].text
}
trace( text_ar[1][1] ); //Traces the text that's entered in instance_1.