Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > ASP.NET Datagrid filling textboxes

Reply
Thread Tools

ASP.NET Datagrid filling textboxes

 
 
Aaron
Guest
Posts: n/a
 
      07-19-2004
I am currently filling textboxes with the data from a datagrid with the
following code:
Sub Fillnextrecord(ByVal e As DataGridCommandEventArgs)

Dim Cell1 As String = e.Item.Cells(1).Text.ToString
Dim Cell2 As String = e.Item.Cells(2).Text.ToString
Dim Cell3 As String = e.Item.Cells(3).Text.ToString
Dim Cell4 As String = e.Item.Cells(4).Text.ToString
Dim Cell5 As String = e.Item.Cells(5).Text.ToString
Dim Cell6 As String = e.Item.Cells(6).Text.ToString
Dim Cell7 As String = e.Item.Cells(7).Text.ToString
Dim Cell8 As String = e.Item.Cells(.Text.ToString
Dim Cell9 As String = e.Item.Cells(9).Text.ToString
Dim Cell10 As String = e.Item.Cells(10).Text.ToString
Dim Cell11 As String = e.Item.Cells(11).Text.ToString
Dim Cell12 As String = e.Item.Cells(12).Text.ToString
Dim Cell13 As String = e.Item.Cells(13).Text.ToString
Dim Cell14 As String = e.Item.Cells(14).Text.ToString
Dim Cell15 As String = e.Item.Cells(15).Text.ToString
Dim Cell16 As String = e.Item.Cells(16).Text.ToString
Dim Cell17 As String = e.Item.Cells(17).Text.ToString



If Cell1.Equals(" ") Then
txtFullname.Text = ""
Else
txtFullname.Text = Trim(Cell1)
End If

If e.Item.Cells(2).Text.Equals(" ") Then
txtCompany.Text = ""

Else
txtCompany.Text = Trim(e.Item.Cells(2).Text)

End If

If e.Item.Cells(3).Text.Equals(" ") Then
txtTitle.Text = ""

Else
txtTitle.Text = Trim(e.Item.Cells(3).Text)

End If
If Cell4.Equals(" ") Then
txtBPhone.Text = ""

Else
txtBPhone.Text = Trim(Cell4)

End If

If e.Item.Cells(5).Text.Equals(" ") Then
txtWorkExt.Text = ""

Else
txtWorkExt.Text = Trim(e.Item.Cells(5).Text)

End If
If e.Item.Cells(6).Text.Equals(" ") Then
txtClientCell.Text = ""

Else
txtClientCell.Text = Trim(e.Item.Cells(6).Text)

End If


If e.Item.Cells(7).Text.Equals(" ") Then
txtNotes.Text = ""

Else
txtNotes.Text = Trim(e.Item.Cells(7).Text)

End If

If e.Item.Cells(9).Text.Equals(" ") Then
txtConfNotes.Text = ""

Else
txtConfNotes.Text = Trim(e.Item.Cells(9).Text)

End If

If e.Item.Cells(10).Text.Equals("&nbsp") Then
txtActDate.Text = ""

Else
txtActDate.Text = Trim(e.Item.Cells(10).Text)

End If

If e.Item.Cells(11).Text.Equals(" ") Then 'If the FU date in
the grid is blank, then run function to count three businessdays
txtFollowUpDate.ForeColor = System.Drawing.Color.Black()
txtFollowUpDate.Text = FormatDateTime
(WebBizDev.Utilities.BusinessDateAdd(FormatDateTim e(Now,
DateFormat.ShortDate), 3), DateFormat.ShortDate)
Else
Dim FUDate As Date = e.Item.Cells(11).Text
If FUDate < FormatDateTime(Now, DateFormat.ShortDate) Then
'ASPNET_MsgBox("The Follow Up Date has expired.")
txtFollowUpDate.ForeColor = System.Drawing.Color.Red()
txtFollowUpDate.Text = Trim(FUDate)
Else
txtFollowUpDate.ForeColor = System.Drawing.Color.Black()
txtFollowUpDate.Text = Trim(e.Item.Cells(11).Text)
End If
End If
If e.Item.Cells(14).Text.Equals("&nbsp;") Then
Label18.Text = ""

Else

Label18.Text = Trim(e.Item.Cells(14).Text)

End If
If e.Item.Cells(15).Text.Equals("&nbsp;") Then
Label19.Text = ""

Else
Label19.Text = Trim(e.Item.Cells(15).Text)

End If
If e.Item.Cells(17).Text.Equals("&nbsp;") Then
txtEmail.Text = ""

Else
txtEmail.Text = Trim(e.Item.Cells(17).Text)

End If
If e.Item.Cells(1.Text.Equals("&nbsp;") Then
txtBMail.Text = ""

Else
txtBMail.Text = Trim(e.Item.Cells(1.Text)

End If
If e.Item.Cells(19).Text.Equals("&nbsp;") Then
txtHomePhone.Text = ""

Else
txtHomePhone.Text = Trim(e.Item.Cells(19).Text)

End If




This is used to fill textboxes for editing the data. Once the data has
been modified, the user hits the "Update Record" button and the changes
are commited to the database.

I need to be able to move to the next record, or row in the datagrid. I
know the e is the datagrideventarg, and that is about it. I have tried e
+1 but that doesn't work.

Could anyone show me how to move to the next record? I am sure this is
not the best way to fill those textboxes, but it is the only way I found
to do it. Perhaps if there is a better approach, you could show me that
and how I would be able to move to the next row or record.

Thanks,
Aaron
 
Reply With Quote
 
 
 
 
Raterus
Guest
Posts: n/a
 
      07-19-2004
First off, yeah I think there are much better ways to do what you are doing, but I don't know what you are doing that you need to go to the next record..?

Second, there is no "next record", at least available from the EventArgs (e). If you need to get to other values that were stored in the datagrid, you'll have to access them via

myDataGrid.Items(rowNumber).cells(0..1..2..3..)

Hope this helps,
--Michael

"Aaron" <(E-Mail Removed)> wrote in message news:Xns952BA644F7E1aaronjonharveycom@207.46.248.1 6...
> I am currently filling textboxes with the data from a datagrid with the
> following code:
> Sub Fillnextrecord(ByVal e As DataGridCommandEventArgs)
>
> Dim Cell1 As String = e.Item.Cells(1).Text.ToString
> Dim Cell2 As String = e.Item.Cells(2).Text.ToString
> Dim Cell3 As String = e.Item.Cells(3).Text.ToString
> Dim Cell4 As String = e.Item.Cells(4).Text.ToString
> Dim Cell5 As String = e.Item.Cells(5).Text.ToString
> Dim Cell6 As String = e.Item.Cells(6).Text.ToString
> Dim Cell7 As String = e.Item.Cells(7).Text.ToString
> Dim Cell8 As String = e.Item.Cells(.Text.ToString
> Dim Cell9 As String = e.Item.Cells(9).Text.ToString
> Dim Cell10 As String = e.Item.Cells(10).Text.ToString
> Dim Cell11 As String = e.Item.Cells(11).Text.ToString
> Dim Cell12 As String = e.Item.Cells(12).Text.ToString
> Dim Cell13 As String = e.Item.Cells(13).Text.ToString
> Dim Cell14 As String = e.Item.Cells(14).Text.ToString
> Dim Cell15 As String = e.Item.Cells(15).Text.ToString
> Dim Cell16 As String = e.Item.Cells(16).Text.ToString
> Dim Cell17 As String = e.Item.Cells(17).Text.ToString
>
>
>
> If Cell1.Equals("&nbsp;") Then
> txtFullname.Text = ""
> Else
> txtFullname.Text = Trim(Cell1)
> End If
>
> If e.Item.Cells(2).Text.Equals("&nbsp;") Then
> txtCompany.Text = ""
>
> Else
> txtCompany.Text = Trim(e.Item.Cells(2).Text)
>
> End If
>
> If e.Item.Cells(3).Text.Equals("&nbsp;") Then
> txtTitle.Text = ""
>
> Else
> txtTitle.Text = Trim(e.Item.Cells(3).Text)
>
> End If
> If Cell4.Equals("&nbsp;") Then
> txtBPhone.Text = ""
>
> Else
> txtBPhone.Text = Trim(Cell4)
>
> End If
>
> If e.Item.Cells(5).Text.Equals("&nbsp;") Then
> txtWorkExt.Text = ""
>
> Else
> txtWorkExt.Text = Trim(e.Item.Cells(5).Text)
>
> End If
> If e.Item.Cells(6).Text.Equals("&nbsp;") Then
> txtClientCell.Text = ""
>
> Else
> txtClientCell.Text = Trim(e.Item.Cells(6).Text)
>
> End If
>
>
> If e.Item.Cells(7).Text.Equals("&nbsp;") Then
> txtNotes.Text = ""
>
> Else
> txtNotes.Text = Trim(e.Item.Cells(7).Text)
>
> End If
>
> If e.Item.Cells(9).Text.Equals("&nbsp;") Then
> txtConfNotes.Text = ""
>
> Else
> txtConfNotes.Text = Trim(e.Item.Cells(9).Text)
>
> End If
>
> If e.Item.Cells(10).Text.Equals("&nbsp") Then
> txtActDate.Text = ""
>
> Else
> txtActDate.Text = Trim(e.Item.Cells(10).Text)
>
> End If
>
> If e.Item.Cells(11).Text.Equals("&nbsp;") Then 'If the FU date in
> the grid is blank, then run function to count three businessdays
> txtFollowUpDate.ForeColor = System.Drawing.Color.Black()
> txtFollowUpDate.Text = FormatDateTime
> (WebBizDev.Utilities.BusinessDateAdd(FormatDateTim e(Now,
> DateFormat.ShortDate), 3), DateFormat.ShortDate)
> Else
> Dim FUDate As Date = e.Item.Cells(11).Text
> If FUDate < FormatDateTime(Now, DateFormat.ShortDate) Then
> 'ASPNET_MsgBox("The Follow Up Date has expired.")
> txtFollowUpDate.ForeColor = System.Drawing.Color.Red()
> txtFollowUpDate.Text = Trim(FUDate)
> Else
> txtFollowUpDate.ForeColor = System.Drawing.Color.Black()
> txtFollowUpDate.Text = Trim(e.Item.Cells(11).Text)
> End If
> End If
> If e.Item.Cells(14).Text.Equals("&nbsp;") Then
> Label18.Text = ""
>
> Else
>
> Label18.Text = Trim(e.Item.Cells(14).Text)
>
> End If
> If e.Item.Cells(15).Text.Equals("&nbsp;") Then
> Label19.Text = ""
>
> Else
> Label19.Text = Trim(e.Item.Cells(15).Text)
>
> End If
> If e.Item.Cells(17).Text.Equals("&nbsp;") Then
> txtEmail.Text = ""
>
> Else
> txtEmail.Text = Trim(e.Item.Cells(17).Text)
>
> End If
> If e.Item.Cells(1.Text.Equals("&nbsp;") Then
> txtBMail.Text = ""
>
> Else
> txtBMail.Text = Trim(e.Item.Cells(1.Text)
>
> End If
> If e.Item.Cells(19).Text.Equals("&nbsp;") Then
> txtHomePhone.Text = ""
>
> Else
> txtHomePhone.Text = Trim(e.Item.Cells(19).Text)
>
> End If
>
>
>
>
> This is used to fill textboxes for editing the data. Once the data has
> been modified, the user hits the "Update Record" button and the changes
> are commited to the database.
>
> I need to be able to move to the next record, or row in the datagrid. I
> know the e is the datagrideventarg, and that is about it. I have tried e
> +1 but that doesn't work.
>
> Could anyone show me how to move to the next record? I am sure this is
> not the best way to fill those textboxes, but it is the only way I found
> to do it. Perhaps if there is a better approach, you could show me that
> and how I would be able to move to the next row or record.
>
> Thanks,
> Aaron

 
Reply With Quote
 
 
 
 
Aaron
Guest
Posts: n/a
 
      07-19-2004
> First off, yeah I think there are much better ways to do what you are
> doing, but I don't know what you are doing that you need to go to the
> next record..?


Basically, the user updates a record and then needs to move to the next
record for editing. They would like to do this with one click of the
"Update Button". (Update the current row, then move to the next one, and
populate the text boxes for editing)


> Second, there is no "next record", at least available from the
> EventArgs (e). If you need to get to other values that were stored in
> the datagrid, you'll have to access them via
>
> myDataGrid.Items(rowNumber).cells(0..1..2..3..)
>
> Hope this helps,

Yes, this does help a lot. Thanks.

Aaron

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagrid not completely filling in webusercontrol page 1 in 4 times. nigel@idsol.co.uk ASP .Net 0 12-21-2005 08:04 AM
Trouble Filling DropDownList in Datagrid David Londeck ASP .Net Web Controls 1 03-28-2005 02:56 PM
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls thegame ASP .Net 1 02-28-2005 04:23 PM
Filling Datagrid Aaron ASP .Net Datagrid Control 4 08-18-2004 07:51 AM
RE: When updating from a DataGrid the canges in textboxes are not detected Jim Cheshire ASP .Net 2 07-29-2003 04:01 PM



Advertisments