Click here to Skip to main content
15,923,789 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Question.NET 2.0 GridView question Pin
Brent Lamborn2-Nov-05 11:33
Brent Lamborn2-Nov-05 11:33 
QuestionProgrammatically popup a menu (seperate thread) Pin
AndrewVos2-Nov-05 11:28
AndrewVos2-Nov-05 11:28 
AnswerRe: Programmatically popup a menu (seperate thread) Pin
AndrewVos2-Nov-05 11:37
AndrewVos2-Nov-05 11:37 
AnswerRe: Programmatically popup a menu (seperate thread) Pin
Pravat Maskey5-Nov-05 21:09
Pravat Maskey5-Nov-05 21:09 
GeneralRe: Programmatically popup a menu (seperate thread) Pin
AndrewVos5-Nov-05 22:58
AndrewVos5-Nov-05 22:58 
QuestionQuestions on validating textbox inputs, and request for a webpage source via VB .NET Pin
xDanELx2-Nov-05 11:20
xDanELx2-Nov-05 11:20 
AnswerRe: Questions on validating textbox inputs, and request for a webpage source via VB .NET Pin
Briga3-Nov-05 0:10
Briga3-Nov-05 0:10 
QuestionUpdate on Grid fails? Pin
Sled Dog2-Nov-05 8:58
Sled Dog2-Nov-05 8:58 
I don't understand this one...

Almost everything works except the Update on the grid: Delete, Cancel, Edit*

If I take the Load_Grid out of m_dgIDs.EditCommand--I have to click the Edit link twice for it to turn into a textbox that I can edit, but the original content is not there.

If I leave the Load_Grid in the EditCommand, the textbox will appear immediately with the cell's content and I can edit it. HOWEVER, the grid no longer appears to be bound and this line blows up:
Dim id As Integer = CType(e.Item.Cells(0).Text, Integer)

e.Item.Cells(0).Text is = "" or nothing

I tried to keep this code to a MIMIMUM because I know it is a lot to ask of forum members, but if someone has the time, I would appreciate any thoughts on the subject.

Thanks - A Lot.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Load_DropDown()
End If
End Sub

Private Sub m_ddFacility_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_ddFacility.SelectedIndexChanged
Load_Grid()
End Sub

Private Sub dgIDs_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.UpdateCommand
'ID is just a simple class that interfaces with the database & has 3 properties
'CostCenterID, FacilityID, & Description...pretty trivial
Dim oCostCenter As New ID
Dim id As Integer = CType(e.Item.Cells(0).Text, Integer)

oCostCenter.Load(id)
oCostCenter.Description = CType(e.Item.Cells(2).Text, String)
oCostCenter.FacilityID = m_ddFacility.SelectedValue
oCostCenter.Update()

Load_Grid()
m_dgIDs.EditItemIndex = -1
End Sub

Private Sub dgIDs_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.EditCommand
m_dgIDs.EditItemIndex = e.Item.ItemIndex

Load_Grid()
End Sub

Private Sub dgIDs_Delete(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.DeleteCommand
Dim oCostCenter As New ID
Dim id As Integer = CType(e.Item.Cells(0).Text, Integer)
oCostCenter.Load(id)
oCostCenter.Delete()

Load_Grid()
End Sub

Private Sub dgIDs_Cancel(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.CancelCommand
m_dgIDs.EditItemIndex = -1

Load_Grid()
End Sub

Private Sub Load_Grid()
Dim ds As DataSet
Dim oData_Dev As New CFormData("DefaultConnectionString")

ds = oData_Dev.GetDataSet("SELECT * FROM CostCenter WHERE FacilityID = " & m_ddFacility.SelectedValue.ToString())

m_dgIDs.DataSource = ds
m_dgIDs.DataBind()
End Sub

Private Sub Load_DropDown()
Dim ds As New DataSet
Dim oData_Dev As New CFormData("DefaultConnectionString")

ds = oData_Dev.GetDataSet("SELECT * FROM Facility")

m_ddFacility.DataSource = ds
m_ddFacility.DataTextField = "FacilityName"
m_ddFacility.DataValueField = "FacilityID"
m_ddFacility.DataBind()
End Sub

---The Page---
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="GridPage.aspx.vb" Inherits="TestEnv.GridPage" %>
<HTML>
<HEAD>
<title>GridPage</title>
<meta content...>
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD colSpan="2">
<asp:datagrid id="m_dgIDs" runat="server" Width="100%" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn Visible="False" DataField="CostCenterID" HeaderText="CostCenterID"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="FacilityID" HeaderText="FacilityID"></asp:BoundColumn>
<asp:BoundColumn DataField="Description" HeaderText="Description"></asp:BoundColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:ButtonColumn>
</Columns>
</asp:datagrid></TD>
</TR>
<TR>
<TD>
<asp:DropDownList id="m_ddFacility" runat="server" AutoPostBack="True"></asp:DropDownList></TD>
</TR>
</TABLE>
</form>
</body>
</HTML>

AnswerRe: Update on Grid fails? Pin
Sled Dog3-Nov-05 7:21
Sled Dog3-Nov-05 7:21 
QuestionCan't use CTRL-V Pin
SignMan3592-Nov-05 7:53
SignMan3592-Nov-05 7:53 
QuestionHow to Post Data to a different domain/url Pin
john_paul2-Nov-05 2:49
john_paul2-Nov-05 2:49 
AnswerRe: How to Post Data to a different domain/url Pin
Leather992-Nov-05 3:21
Leather992-Nov-05 3:21 
GeneralRe: How to Post Data to a different domain/url Pin
Leather992-Nov-05 5:44
Leather992-Nov-05 5:44 
GeneralRe: How to Post Data to a different domain/url Pin
john_paul2-Nov-05 6:59
john_paul2-Nov-05 6:59 
GeneralRe: How to Post Data to a different domain/url Pin
john_paul2-Nov-05 7:59
john_paul2-Nov-05 7:59 
GeneralRe: How to Post Data to a different domain/url Pin
Leather992-Nov-05 21:57
Leather992-Nov-05 21:57 
QuestionProblem running rwrun60 ... Pin
Pescador342-Nov-05 0:53
Pescador342-Nov-05 0:53 
AnswerRe: Problem running rwrun60 ... Pin
Dave Kreskowiak2-Nov-05 6:45
mveDave Kreskowiak2-Nov-05 6:45 
GeneralRe: Problem running rwrun60 ... Pin
Pescador342-Nov-05 22:16
Pescador342-Nov-05 22:16 
GeneralRe: Problem running rwrun60 ... Pin
cmarguello25-Sep-09 12:39
cmarguello25-Sep-09 12:39 
QuestionDatabase Help Pin
Deepu kuttan1-Nov-05 23:42
Deepu kuttan1-Nov-05 23:42 
AnswerRe: Database Help Pin
KaptinKrunch2-Nov-05 7:36
KaptinKrunch2-Nov-05 7:36 
QuestionHow to build a patch application Pin
Mekong River1-Nov-05 21:56
Mekong River1-Nov-05 21:56 
AnswerRe: How to build a patch application Pin
Leather992-Nov-05 3:23
Leather992-Nov-05 3:23 
GeneralRe: How to build a patch application Pin
Mekong River6-Nov-05 13:46
Mekong River6-Nov-05 13:46 

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.