Click here to Skip to main content
16,006,001 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah15-Oct-12 5:46
zaimah15-Oct-12 5:46 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen15-Oct-12 6:13
professionalEddy Vluggen15-Oct-12 6:13 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah15-Oct-12 13:48
zaimah15-Oct-12 13:48 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen16-Oct-12 0:14
professionalEddy Vluggen16-Oct-12 0:14 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah16-Oct-12 2:35
zaimah16-Oct-12 2:35 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen16-Oct-12 2:42
professionalEddy Vluggen16-Oct-12 2:42 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah16-Oct-12 2:59
zaimah16-Oct-12 2:59 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen16-Oct-12 3:17
professionalEddy Vluggen16-Oct-12 3:17 
zaimah wrote:
Do u mean the example that u gave me:

VB
Dim C1S As Integer = DirectCast(row.FindControl("Label1"), TextBox).Text
            Dim C1 As Integer = Convert.ToInt32(C1S) 
That's not the example I gave you - the one you shown here tries to assign a string to an integer. This was the example;
VB
Dim C1S As String = DirectCast(row.FindControl("Label1"), TextBox).Text
Dim C1 As Integer = Convert.ToInt32(C1S)


zaimah wrote:
Sorry, my english s not that good Frown | :(

It's good enough; we're making progress Smile | :)

zaimah wrote:
I have try using this method. It didn't work. How to check the value 1st and if its Null, put '0' in it?

The problem with the line is that it does multiple things at once; it contains multiple instructions. It get's easier if you divide it into smaller pieces, as smaller problems are easier to conquer.

So, first one needs to find the control. You already know how to do that;
VB
Dim TextBoxC1 As TextBox = DirectCast(row.FindControl("TextBox1"), TextBox)

Then, put a breakpoint on that line, and make sure it can actually find the control. If it doesn't, it might generate an exception, claiming it's null.

Once you got the correct control, you get it's value. Keep in mind that textboxes (and labels) contain strings, and that an empty string might be equal to null again. For an integer, we'd do something like the example; Convert.ToInt32 will change a "null" to 0. If you're saving a string, you'd use Convert.ToString. So, the code would continue like this;
VB
Dim TextBoxC1 As TextBox = DirectCast(row.FindControl("TextBox1"), TextBox)
Dim ValueC1 As String = Convert.ToString(TextBoxC1.Text) ' assuming you save a text, not a number

Once you got that, you can check whether "ValueC1" is "null" or an actual value (and replace it if required).
Bastard Programmer from Hell Suspicious | :suss:
if you can't read my code, try converting it here[^]

GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah16-Oct-12 3:50
zaimah16-Oct-12 3:50 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen16-Oct-12 4:21
professionalEddy Vluggen16-Oct-12 4:21 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah17-Oct-12 4:13
zaimah17-Oct-12 4:13 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen17-Oct-12 4:51
professionalEddy Vluggen17-Oct-12 4:51 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah17-Oct-12 5:25
zaimah17-Oct-12 5:25 
GeneralRe: How to update Gridview with value textbox = Null Pin
zaimah17-Oct-12 6:04
zaimah17-Oct-12 6:04 
GeneralRe: How to update Gridview with value textbox = Null Pin
Eddy Vluggen17-Oct-12 9:20
professionalEddy Vluggen17-Oct-12 9:20 
AnswerRe: [SOLVED] How to update Gridview with value textbox = Null Pin
josephSurgeon31-Oct-12 4:27
josephSurgeon31-Oct-12 4:27 
QuestionIndex was outside the bounds of the array Pin
etteychan12-Oct-12 19:03
etteychan12-Oct-12 19:03 
AnswerRe: Index was outside the bounds of the array Pin
Richard MacCutchan12-Oct-12 21:07
mveRichard MacCutchan12-Oct-12 21:07 
QuestionConfused by my own code: LINQ FirstOrDefault Pin
Steven St. John11-Oct-12 13:18
Steven St. John11-Oct-12 13:18 
AnswerRe: Confused by my own code: LINQ FirstOrDefault Pin
Steven St. John16-Oct-12 6:58
Steven St. John16-Oct-12 6:58 
QuestionVB.NET Parameters error Pin
Diego Carrion11-Oct-12 4:12
Diego Carrion11-Oct-12 4:12 
AnswerRe: VB.NET Parameters error Pin
Simon_Whale11-Oct-12 4:45
Simon_Whale11-Oct-12 4:45 
GeneralRe: VB.NET Parameters error Pin
Diego Carrion11-Oct-12 4:47
Diego Carrion11-Oct-12 4:47 
GeneralRe: VB.NET Parameters error Pin
ChandraRam11-Oct-12 11:06
ChandraRam11-Oct-12 11:06 
QuestionSlow Ping and not guaranteed success Pin
Herboren10-Oct-12 5:44
Herboren10-Oct-12 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.