hello,
new to vb.net, have a few questions about DataGrid. I have a dataGrid
that is working pulling a dataset back from a stored proc and binding
to the datagrid for display
the datagrid's first column is a textbox(TemplateColumn), the other 3
columns are just display(BoundColumn).
(1) if the value of the textbox is 0, then i'd like to change it null,
so the box is empty
i tried this...
For Each PickGridItem In draftPickGrid.Items
If Convert.ToInt16(CType(PickGridItem.FindControl("tP riority"),
TextBox).Text) = 0 Then
CType(PickGridItem.FindControl("tPriority"), TextBox).Text = ""
End If
Next
this or variation of it didn't work. help?
(2) after the user click the button, I have a function that kicks off
that i wanted to loop the dataset, get a few values (one if which is
the textbox), and then call a proc to update the data
i tried this....
For Each DemoGridItem In draftPickGrid.Items
EventId = Convert.ToInt16(DemoGridItem.Cells(2).Text)
Priority =
Convert.ToInt16(CType(DemoGridItem.FindControl("tP riority"),
TextBox).Text)
DraftPicks.UpdateDraftPick(groupID, EventId, userID, Priority)
Next
I was getting a "Object reference not set to an instance of an object"
on Priority
also tried these lines to capture the value of the textbox
Dim tb As TextBox
tb = DemoGridItem.FindControl("tPriority")
Priority = Convert.ToInt16(tb.Text)
that didn't work either, same error
i'm using visual studio 2003 and put a break point on the function
that is called to loop and call the update proc, i have these
declaration lines at the top of the function
Dim EventId As Integer
Dim Priority As Integer
Dim DemoGridItem As DataGridItem
Dim DraftPicks As New DraftPicksDB
it will skip over the first three Dim lines, Dim the 4th and then move
to the for loop. in the loop when i hit the priority (textbox)
processing line the error is then thrown.
any help/advice would be appreciated - sample code is always welcome
:)
thanks in advance!