Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

the code is long so i made a .vb of it

 

i have 2 datagrids that updates and inserts infornation on a database

 

one of them have a insert new row via a button

 

Public Sub cb_insert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cb_insert.Click

Dim oCmd As New SqlClient.SqlCommand()

oCmd.CommandText = "INSERT INTO dbo.Issue(volno,issueno,issueperiod,year) SELECT MAX(volno) + 1,1,'New Issue',max(year) + 1 FROM dbo.Issue"

oCmd.Connection = daDGIssue.SelectCommand.Connection

oCmd.Connection.Open()

Try

oCmd.ExecuteNonQuery()

RefreshVolumeList()

Catch err As SqlClient.SqlException

txtmsg.Text = err.Message

Return

End Try

dgIssue.EditItemIndex = dgIssue.Items.Count

FinishPage()

End Sub

it would create a new row on the bottom of the first datagrid and when u click edit it becomes editable. when u click the update button it would do insert since it would do this

 

If dsDGIssue.Tables(0).Rows(nIdx).RowState = DataRowState.Added Then

oCmd = New SqlClient.SqlCommand()

With oCmd

oCmd.CommandText = "INSERT INTO dbo.Issue(volno,issueno,issueperiod,year, MagazineTitle, notes)" _

& " VALUES(@VolNo,@IssueNo, @IssuePer, @Year, @MagTitle, @Notes) "

 

.Parameters.Add("@VolNo", dgVolno)

.Parameters.Add("@IssueNo", uIssueNo)

.Parameters.Add("@IssuePer", uIssuePeriod)

.Parameters.Add("@Year", uYear)

.Parameters.Add("@MagTitle", uMagTitle)

.Parameters.Add("@Notes", uNotes)

.Connection = daDGIssue.SelectCommand.Connection

End With

the 2nd datagrid has information inserted when a linkbutton on the first datagrid is pushed

but when i click update it goes to this

 

Else

oCmd = daCover.UpdateCommand

daCover.UpdateCommand.Parameters("@IssueId").Value = dgIssueid

daCover.UpdateCommand.Parameters("@Caption").Value = uCaption

daCover.UpdateCommand.Parameters("@PhotogCreditID").Value = uname

daCover.UpdateCommand.Parameters("@tn_width").Value = uTnwidth

daCover.UpdateCommand.Parameters("@tn_height").Value = uTnHeight

daCover.UpdateCommand.Parameters("@Large_image").Value = uLargeimage

daCover.UpdateCommand.Parameters("@full_width").Value = uFullwidth

daCover.UpdateCommand.Parameters("@full_height").Value = uFullheight

daCover.UpdateCommand.Parameters("@Notes").Value = uNotes

daCover.UpdateCommand.Parameters("@Image").Value = utnImage

End If

 

If oCmd.Connection.State = ConnectionState.Closed Then

oCmd.Connection.Open()

End If

 

Try

oCmd.ExecuteNonQuery()

Catch err As SqlClient.SqlException

txtmsg.Text = err.Message

Return

End Try

oCmd.Connection.Close()

 

' reload data so we refect what was actually saved

LoadDataSet()

dgCover.EditItemIndex = -1

FinishPage()

dgCover.Visible = True

End Sub

and since there is no physical attributes it doesn't update

 

when i do a quickwatch on DsCover.Tables(0).Rows(nIdx).RowState it states that it was unchanged

 

don't know why :mad: :confused: :-\

webform1.aspx.vb

Edited by wayko
  • Leaders
Posted

where is nIdx coming from? have you tried HasChanges() on the dataset to see if it is reporting any changes -- maybe you just don't have the right nIdx.

 

on a side note, it looks like you're going through the trouble of setting up the dataAdapter, why not just call it's update method and let it figure this stuff out for you?

--tim
Posted

If dsDGIssue.Tables(0).Rows(nIdx).RowState always says unchanged

i tried If dsDGIssue.Tables(0).Rows(nIdx).RowState <> DataRowState.Added it works the first time but since it always unchanged it would never update i tried doing a work around but thats not the way to go

Posted

also is there a way to set a cursor to blink on a textbox on load

ie peron goes in webform and the first textbox already has the cursor blinking and waiting no need for mouse click

  • Leaders
Posted

Have you checked HasChanges() on the whole dataset?

 

You should start a new thread when you have totally unrelated questions. but as far as I know you can't change the client's cursor on a webform.

--tim
Posted

no i haven't

i tried DsCover.Tables(0).Rows(nIdx).RowState.Unchanged = DataRowState.Added

still the same problem

the funny thing is when i do it to another datagrid using a button on the form it works fine

but when i do it from a datagrid button i get the error

  • Leaders
Posted

With your "blinking cursor" question, I misunderstood you. The textbox has a .focus() method that you can use the body's onLoad() event to call. You could look at the source behind most any professional web page and see this in action, Google is an example.

 

As it turns out, I was also wrong about the answer I gave to what I thought the question was. It turns out you *can* change the cursor using CSS on the client. I'm not sure all the options but I just saw where you can change it to the question mark by

a:hover{cursor:help} in the stylesheet. Not that this was your question, I just like to follow up when I give bum scoop:(

--tim

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...