473,394 Members | 1,841 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,394 software developers and data experts.

Problem with String Data Type

I'm working with a DataGrid UpdateCommand event and running into a problem.
The second column of the dg is the PK named "FlitchNum". The datatype of
this PK is varchar(string). In the event I need to obtain the value of this
field in order to pass it into a SQL command. However, when I use the
syntax: "Dim FlitchID As String = e.Item.Cells(1).Text" nothing populates the
FlitchID variable. Below is the code. How do I simply select the textual
value of the contents of column 3? Thanks
-------------------------------------------------------------------------------------
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) _
Handles DataGrid1.UpdateCommand
Dim DDL As DropDownList = _
CType(e.Item.Cells(2).Controls(1), DropDownList)
Dim NewShip As Integer = DDL.SelectedValue
Dim FlitchID As String = e.Item.Cells(1).Text
Response.Write(FlitchID)
Dim SQL As String = _
"UPDATE tblLogs SET SpecieID=@Specie WHERE FlitchID=@ID"
Dim Conn As SqlConnection = New SqlConnection("integrated
security=SSPI;data source=sjserver1;persist security info=False;initial
catalog=sjerp")
Dim Cmd As New SqlCommand(SQL, Conn)
Cmd.Parameters.Add(New SqlParameter("@Specie", NewShip))
Cmd.Parameters.Add(New SqlParameter("@ID", FlitchID))
Conn.Open()
Cmd.ExecuteNonQuery()
Conn.Close()
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind(
-------------------------------------------------------------------------------------
Jul 21 '05 #1
4 1280
MrMike <Mr****@discussions.microsoft.com> wrote:
I'm working with a DataGrid UpdateCommand event and running into a problem.
The second column of the dg is the PK named "FlitchNum". The datatype of
this PK is varchar(string). In the event I need to obtain the value of this
field in order to pass it into a SQL command. However, when I use the
syntax: "Dim FlitchID As String = e.Item.Cells(1).Text" nothing populates the
FlitchID variable.


That sounds very strange. Does e.Item.Cells(1).Text definitely have a
non-null value? How are you determining that FlitchID has not been set?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Thanks for your reply. FlitchNum is the PK, so it cannot contain a null
value. This column is a template column, generated using the code below.
Should this make any difference? Thanks.

<asp:TemplateColumn HeaderText="Flitch#">
<ItemTemplate>
<asp:HyperLink runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.FlitchNum") %> ' NavigateURL='<%# "Logs_Detail.aspx?id=" &
DataBinder.Eval(Container, "DataItem.FlitchNum") %>' Target="_self"
Name="HyperLink1">
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>


"Jon Skeet [C# MVP]" wrote:
MrMike <Mr****@discussions.microsoft.com> wrote:
I'm working with a DataGrid UpdateCommand event and running into a problem.
The second column of the dg is the PK named "FlitchNum". The datatype of
this PK is varchar(string). In the event I need to obtain the value of this
field in order to pass it into a SQL command. However, when I use the
syntax: "Dim FlitchID As String = e.Item.Cells(1).Text" nothing populates the
FlitchID variable.


That sounds very strange. Does e.Item.Cells(1).Text definitely have a
non-null value? How are you determining that FlitchID has not been set?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #3
MrMike <Mr****@discussions.microsoft.com> wrote:
Thanks for your reply. FlitchNum is the PK, so it cannot contain a null
value.
That may be true in theory, but is it true in your particular case? It
seems more likely that that would be wrong than that variable
assignment is broken.
This column is a template column, generated using the code below.
Should this make any difference? Thanks.


Don't know, I'm afraid...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
Your FlitchNum is stored in the HyperLink's Text attribute, not in the Text
attribute of the DataGrid's Cell.

You need to give your HyperLink an ID and use e.FindControl("<ID>") to get
an instance of your control and cast it to the type of HyperLink. Then you
can extract the FlitchNum from the control's Text property.
"Jon Skeet [C# MVP]" wrote:
MrMike <Mr****@discussions.microsoft.com> wrote:
Thanks for your reply. FlitchNum is the PK, so it cannot contain a null
value.


That may be true in theory, but is it true in your particular case? It
seems more likely that that would be wrong than that variable
assignment is broken.
This column is a template column, generated using the code below.
Should this make any difference? Thanks.


Don't know, I'm afraid...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: john | last post by:
Hi,All Gurus: It is kind of complicated, please bear with me and let me know if you have any questions. Thanks a lot in advance. John I have a csharp method, using emit to dynamically generate...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
2
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import...
2
by: Ch Pravin | last post by:
Hi All: I am having the following xml which i need to convert to excel using xslt. Please help me out. Afghanistan.xml <?xml version="1.0" encoding="utf-16"?> <Languages...
0
by: phpfreak2007 | last post by:
Hi all, I am trying to upload file using VB HTTP Post method and winsock control . Can successfully upload the files when client machine is English OS, but create problem when upload from Chinese...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
10
by: oktayarslan | last post by:
Hi all; I have a problem when inserting an element to a vector. All I want is reading some data from a file and putting them into a vector. But the program is crashing after pushing a data which...
1
by: aboalnodom | last post by:
hello guys, i hope any one will help in this i am designing a web application, the page i am workin on its the default.aspx it contains dropdownboxes the first 4 to choose the type and the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.