Click here to Skip to main content
15,921,203 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Generali need dynamic query with different criteria Pin
MAGICIANMERLIN7-Aug-05 4:07
MAGICIANMERLIN7-Aug-05 4:07 
GeneralRe: i need dynamic query with different criteria Pin
Christian Graus7-Aug-05 13:56
protectorChristian Graus7-Aug-05 13:56 
GeneralRe: i need dynamic query with different criteria Pin
MAGICIANMERLIN8-Aug-05 10:55
MAGICIANMERLIN8-Aug-05 10:55 
GeneralRe: i need dynamic query with different criteria Pin
Christian Graus8-Aug-05 13:16
protectorChristian Graus8-Aug-05 13:16 
GeneralRichTextBox Pin
SeLoRBIS7-Aug-05 1:49
SeLoRBIS7-Aug-05 1:49 
QuestionHow can get Received value in LocalNetwork Connecttion Pin
Anonymous7-Aug-05 1:45
Anonymous7-Aug-05 1:45 
AnswerRe: How can get Received value in LocalNetwork Connecttion Pin
Dave Kreskowiak7-Aug-05 4:47
mveDave Kreskowiak7-Aug-05 4:47 
GeneralStuck on Getting a Changed Value in a DropDownList within a DataList Pin
asalyon6-Aug-05 15:08
asalyon6-Aug-05 15:08 
I am trying to use a DropDownList for displaying and changing data within a database. As soon as I select a new value from the list and click the change link then look at the DropDownList selected index value in the Update_Command function it has changed back to the original value. Is there a way to capture the new value before the bind occurs so I can update the database?


---Code-----------------------------------------------------

<%@ Import Namespace="System.Data.OleDb"%>
<%@ Import Namespace="System.Data" %>

<%@ Page
Language="vb"
ValidateRequest="false"
AutoEventWireup="false"
enableViewState="True" %>
<%@ Import Namespace="nsGlobal" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Web Page</title>
<link rel="stylesheet" type="text/css" href="http://www.access.org/Aspx.css" media="screen">

<script language="VB" runat=server>

Dim sql as String
Dim idx as Integer
Dim StrucEvents as New clsStrucEvents


Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Request.IsSecureConnection Then
Dim sUrl as string
sUrl = Request.Url.ToString.Replace("http://www.access.org/",ConfigurationSettings.AppSettings("SecureUrl"))
Response.Redirect(sUrl)
End If

If Not IsPostBack Then
Dim PageStats as New clStats
PageStats.Load_PageStats()
End If

Fill_DonerDl

End Sub

Function ListTitleBlock() as String
Dim html as String
html = "<h2>"
html = html & "Doner List for "
html = html & StrucEvents.Id
html = html & "</h2>"
Return html

End Function

Sub Cancel_Command(ByVal sender As Object, ByVal e As DataListCommandEventArgs)
dlEventDonor.EditItemIndex = -1
dlEventDonor.DataBind()
End Sub

Sub Edit_Command(ByVal sender As Object, ByVal e As DataListCommandEventArgs)
dlEventDonor.EditItemIndex = e.Item.ItemIndex
dlEventDonor.DataBind()
End Sub


Sub Update_Command(ByVal sender As Object, ByVal e As DataListCommandEventArgs)
Dim strlstEdY as String, strlstEdD as String
strlstEdY = CType(e.Item.FindControl("lstEdY"), DropDownList).SelectedItem.Value
strlstEdD = CType(e.Item.FindControl("lstEdD"), DropDownList).SelectedItem.Value
Response.Write(strlstEdY & " " & strlstEdD & "<hr>")
End Sub

Sub Delete_Command(ByVal sender As Object, ByVal e As DataListCommandEventArgs)
End Sub


Function Fill_DataSource(strFld as String) as DataSet

Dim ds as DataSet = New DataSet()
Dim tbl As DataTable = New DataTable("tbl")
Dim col As DataColumn = New DataColumn(strFld)
tbl.Columns.Add(col)
ds.Tables.Add(tbl)
Dim Row As DataRow

Dim idx as integer

Select Case strFld
Case "EdY"
For idx = -4 to 5
Row = tbl.NewRow()
Row(strFld) = CStr(Year(DateAdd("yyyy",idx,Now)))
tbl.Rows.Add(Row)
Next

Case "EdM"
For idx = 1 to 12
Row = tbl.NewRow()
Row(strFld) = CStr(idx)
tbl.Rows.Add(Row)
Next
Case "EdD"
For idx = 1 to 31
Row = tbl.NewRow()
Row(strFld) = CStr(idx)
tbl.Rows.Add(Row)
Next

End Select

Session(strFld) = ds
Return ds

End Function

Function Get_SelectedIndex(strFld as String,strValue as string) as Integer
Dim iLoop as Integer

Dim dt as DataTable = Session(strFld).Tables("tbl")
For iLoop = 0 to dt.Rows.Count - 1
If strValue = dt.Rows(iLoop)(strFld) then
Return iLoop
End If
Next iLoop

End Function


''''''''''''''''''''''''''''''''
'''Database Access Functions '''
'\/''''''''''''''''''''''''''\/'
Private Sub Fill_DonerDl()

Dim objConn As OleDbConnection
Dim objComd As OleDbDataAdapter
Dim sql As String
Dim objDs as DataSet = New DataSet()
StrucEvents = Session("StrucEvents")

'On Error Resume Next

objConn = New OleDbConnection(ConfigurationSettings.AppSettings("Conn"))

sql = "SELECT "
sql = sql & "TblEventDonor.* "
sql = sql & "FROM TblEventDonor "
sql = sql & "WHERE "
sql = sql & "EdId = '" & StrucEvents.Id & "' "
sql = sql & ";"
'Response.Write(sql & "<hr>")
objComd = New OleDbDataAdapter(sql, objConn)
objComd.Fill(objDs,"TblEventDonor")

dlEventDonor.Datasource=objDs.Tables("TblEventDonor").DefaultView

DataBind()

objComd.Dispose()
objDs.Dispose()
objConn.Close()

End Sub

</script>

</HEAD>
<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

<div id='PageBox' style='width:100%;Left:0px;'>

<asp:DataList
runat="server"
Id="dlEventDonor"
BorderColor="#FFEF00"
BorderWidth="1"
GridLines="Both"
CellPadding="3"
CellSpacing="0"
OnEditCommand="Edit_Command"
OnCancelCommand="Cancel_Command"
OnUpdateCommand="Update_Command"
OnDeleteCommand="Delete_Command"
>

<HeaderTemplate>
<%# ListTitleBlock() %>
</HeaderTemplate>
<ItemTemplate>
<div class="Section1a">
<%# Container.DataItem("EdY")%>
<%# Container.DataItem("EdM")%>
<%# Container.DataItem("EdD")%>
<%# Container.DataItem("EdDonor")%>

<asp:LinkButton
Text="Edit"
CommandName="Edit"
Runat="server"
ID="edit" />
<asp:LinkButton
Text="Delete"
CommandName="Delete"
Runat="server"
ID="delete" />

<br>
</div>
</ItemTemplate>

<EditItemTemplate>
Year
..Month
<br>...Day:
<asp:Dropdownlist
DataTextField="EdY"
DataSource='<%# Fill_DataSource("EdY") %>'
SelectedIndex='<%# Get_SelectedIndex("EdY", Container.DataItem("EdY")) %>'
runat=server
ID="lstEdY"/>
</asp:Dropdownlist>

<asp:Dropdownlist
DataValueField="EdM"
DataTextField="EdM"
DataSource='<%# Fill_DataSource("EdM") %>'
SelectedIndex='<%# Get_SelectedIndex("EdM", Container.DataItem("EdM")) %>'
runat=server
ID="lstEdM"/>
</asp:Dropdownlist>

<asp:Dropdownlist
DataValueField="EdD"
DataTextField="EdD"
DataSource='<%# Fill_DataSource("EdD") %>'
SelectedIndex='<%# Get_SelectedIndex("EdD", Container.DataItem("EdD")) %>'
runat=server
ID="lstEdD"/>
</asp:Dropdownlist>

<asp:TextBox
Text='<%# DataBinder.Eval(Container.DataItem, "EdDonor") %>'
runat=server
ID="txtEdDonor"/>

<br>
<asp:LinkButton
id="button2"
runat="server"
Text="Update"
CommandName="update" />
<asp:LinkButton
id="button3"
runat="server"
Text="Cancel"
CommandName="cancel" />
</EditItemTemplate>

</ASP:DataList>
</div>
</form>
</body>
</HTML>


Thanks for any help!!

Steve
GeneralRe: Stuck on Getting a Changed Value in a DropDownList within a DataList Pin
Christian Graus8-Aug-05 19:05
protectorChristian Graus8-Aug-05 19:05 
GeneralDeclarative Security w/ custom principal Pin
Moonark6-Aug-05 11:43
Moonark6-Aug-05 11:43 
GeneralEXECUTENONQUERY Pin
MAGICIANMERLIN6-Aug-05 9:34
MAGICIANMERLIN6-Aug-05 9:34 
GeneralRe: EXECUTENONQUERY Pin
rwestgraham7-Aug-05 17:52
rwestgraham7-Aug-05 17:52 
GeneralRe: EXECUTENONQUERY Pin
MAGICIANMERLIN8-Aug-05 10:51
MAGICIANMERLIN8-Aug-05 10:51 
GeneralRemote system information Pin
Anonymous6-Aug-05 6:11
Anonymous6-Aug-05 6:11 
GeneralRe: Remote system information Pin
Rizwan Bashir8-Aug-05 11:34
Rizwan Bashir8-Aug-05 11:34 
GeneralDatagrid Images Pin
Anonymous6-Aug-05 0:54
Anonymous6-Aug-05 0:54 
GeneralRe: Reports Pin
Anonymous5-Aug-05 23:59
Anonymous5-Aug-05 23:59 
GeneralRe: Reports Pin
Christian Graus7-Aug-05 13:57
protectorChristian Graus7-Aug-05 13:57 
GeneralRe: Reports Pin
Anonymous7-Aug-05 19:38
Anonymous7-Aug-05 19:38 
GeneralRe: Reports Pin
Christian Graus8-Aug-05 13:08
protectorChristian Graus8-Aug-05 13:08 
GeneralRe: Reports Pin
Anonymous8-Aug-05 18:58
Anonymous8-Aug-05 18:58 
GeneralRe: Reports Pin
Christian Graus8-Aug-05 19:03
protectorChristian Graus8-Aug-05 19:03 
GeneralRe: Reports Pin
Anonymous8-Aug-05 20:30
Anonymous8-Aug-05 20:30 
GeneralRe: Reports Pin
Christian Graus8-Aug-05 20:40
protectorChristian Graus8-Aug-05 20:40 
GeneralRe: Reports Pin
Anonymous8-Aug-05 20:49
Anonymous8-Aug-05 20:49 

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.