Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDownlist inside Detailsview probem updating and deleting

Status
Not open for further replies.

Padmajak

Programmer
Jun 7, 2008
10
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="viewmemberdetails.aspx.vb" Inherits="admin_business_viewmemberdetails" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title>Untitled Page</title>
</head>

<body bgcolor="#cccccc">
<form id="form1" runat="server">

<table align="center" >
<tr><td style="width: 274px">
<b>Choose a Member:</b>
<asp:DropDownList ID="dbMembers" DataSourceID="SqlDataSource2" AutoPostBack="true"
DataTextField="businessname" runat="server" OnSelectedIndexChanged="dbMembers_SelectedIndexChanged" />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" SelectCommand="SELECT DISTINCT [businessname] FROM [tbl_memberbusiness]"
ConnectionString="<%$ ConnectionStrings:connstr %>" />

<br />
<br />

<br /></td>
</tr>
<tr>

<td valign="top">
<asp:GridView ID="GridView1" AllowSorting="True" AllowPaging="True" runat="server"
DataSourceID="SqlDataSource1" DataKeyNames="businessname"
AutoGenerateColumns="False" Width="427px" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnSorted="GridView1_Sorted" CellPadding="4" ForeColor="#333333" GridLines="None">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="businessname" HeaderText="BusinessName" ReadOnly="True" SortExpression="BusinessName" />
<asp:BoundField DataField="ownername" HeaderText="OwnerName" SortExpression="OwnerName" />

</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT [businessname], [ownername] FROM [tbl_memberbusiness] WHERE ([businessname] = @businessname)"
ConnectionString="<%$ ConnectionStrings:connstr %>">
<SelectParameters>
<asp:ControlParameter ControlID="dbMembers" Name="businessname" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
<tr><td></td></tr>
<tr>
<td valign="top" style="width: 274px">
<asp:DetailsView AutoGenerateRows="False" DataKeyNames="businessname" OnItemUpdated="DetailsView1_ItemUpdated" onitemdeleting="DetailsView1_ItemDeleting"
DataSourceID="SqlDataSource3" autogeneratedeletebutton="True"

HeaderText="Member Details" ID="DetailsView1" runat="server" Width="500px" CellPadding="4" ForeColor="#333333" GridLines="None">

<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<EditRowStyle BackColor="#999999" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />


<Fields>
<asp:BoundField DataField="businessname" HeaderText="Business Name" ReadOnly="True" SortExpression="businessname" />
<asp:BoundField DataField="ownername" HeaderText="Owner Name" SortExpression="ownername" />
<asp:BoundField DataField="password" HeaderText="Password" SortExpression="password" />
<asp:BoundField DataField="webaddress" HeaderText="Web Address" SortExpression="webaddress" />
<asp:BoundField DataField="address" HeaderText="Address" SortExpression="address" />
<asp:BoundField DataField="city" HeaderText="City" SortExpression="city" />

<asp:TemplateField HeaderText="state" >
<EditItemTemplate>

<asp:dropdownlist id="drpState" runat="server" Width="229px" datavaluefield = "state" DataTextField="state" AutoPostBack="true">
<asp:ListItem Value="XX" >Please Select a State</asp:ListItem>
<asp:ListItem Value="XX">None</asp:ListItem>
<asp:ListItem Value="XX">Outside USA</asp:ListItem>
<asp:ListItem Value="AB">Alberta</asp:ListItem>
<asp:ListItem Value="BC">British Columbia</asp:ListItem>
<asp:ListItem Value="MA">Manitoba</asp:ListItem>
<asp:ListItem Value="NB">New Brunswick</asp:ListItem>
<asp:ListItem Value="NF">Newfoundlandk</asp:ListItem>
<asp:ListItem Value="NT">Northwest Territories</asp:ListItem>
<asp:ListItem Value="NS">Nova Scotia</asp:ListItem>
<asp:ListItem Value="OT">Ontario</asp:ListItem>
<asp:ListItem Value="PE">Prince Edward Island</asp:ListItem>
<asp:ListItem Value="QC">Qu&#233;bec</asp:ListItem>
<asp:ListItem Value="SW">Saskatchewan</asp:ListItem>
<asp:ListItem Value="AL">Alabama</asp:ListItem>
<asp:ListItem Value="AK">Alaska</asp:ListItem>
<asp:ListItem Value="AZ">Arizona</asp:ListItem>
<asp:ListItem Value="AR">Arkansas</asp:ListItem>
<asp:ListItem Value="AE">Armed Forces-Europe</asp:ListItem>
<asp:ListItem Value="AP">Armed Forces-Pacific</asp:ListItem>
<asp:ListItem Value="CA">California</asp:ListItem>
<asp:ListItem Value="CO">Colorado</asp:ListItem>
<asp:ListItem Value="CT">Connecticut</asp:ListItem>
<asp:ListItem Value="DE">Delaware</asp:ListItem>
<asp:ListItem Value="DC">District Of Columbia</asp:ListItem>
<asp:ListItem Value="FL">Florida</asp:ListItem>
<asp:ListItem Value="GA">Georgia</asp:ListItem>
<asp:ListItem Value="HI">Hawaii</asp:ListItem>
<asp:ListItem Value="ID">Idaho</asp:ListItem>
<asp:ListItem Value="IL">Illinois</asp:ListItem>
<asp:ListItem Value="IN">Indiana</asp:ListItem>
<asp:ListItem Value="IA">Iowa</asp:ListItem>
<asp:ListItem Value="KS">Kansas</asp:ListItem>
<asp:ListItem Value="KY">Kentucky</asp:ListItem>
<asp:ListItem Value="LA">Louisiana</asp:ListItem>
<asp:ListItem Value="ME">Maine</asp:ListItem>
<asp:ListItem Value="MD">Maryland</asp:ListItem>
<asp:ListItem Value="MA">Massachusetts</asp:ListItem>
<asp:ListItem Value="MI">Michigan</asp:ListItem>
<asp:ListItem Value="MN">Minnesota</asp:ListItem>
<asp:ListItem Value="MS">Mississippi</asp:ListItem>
<asp:ListItem Value="MO">Missouri</asp:ListItem>
<asp:ListItem Value="MT">Montana</asp:ListItem>
<asp:ListItem Value="NE">Nebraska</asp:ListItem>
<asp:ListItem Value="NV">Nevada</asp:ListItem>
<asp:ListItem Value="NH">New Hampshire</asp:ListItem>
<asp:ListItem Value="NJ">New Jersey</asp:ListItem>
<asp:ListItem Value="NM">New Mexico</asp:ListItem>
<asp:ListItem Value="NY">New York</asp:ListItem>
<asp:ListItem Value="NC">North Carolina</asp:ListItem>
<asp:ListItem Value="ND">North Dakota</asp:ListItem>
<asp:ListItem Value="OH">Ohio</asp:ListItem>
<asp:ListItem Value="OK">Oklahoma</asp:ListItem>
<asp:ListItem Value="OR">Oregon</asp:ListItem>
<asp:ListItem Value="PA">Pennsylvania</asp:ListItem>
<asp:ListItem Value="RI">Rhode Island</asp:ListItem>
<asp:ListItem Value="SC">South Carolina</asp:ListItem>
<asp:ListItem Value="SD">South Dakota</asp:ListItem>
<asp:ListItem Value="TN">Tennessee</asp:ListItem>
<asp:ListItem Value="TX">Texas</asp:ListItem>
<asp:ListItem Value="UT">Utah</asp:ListItem>
<asp:ListItem Value="VT">Vermont</asp:ListItem>
<asp:ListItem Value="VA">Virginia</asp:ListItem>
<asp:ListItem Value="WA">Washington</asp:ListItem>
<asp:ListItem Value="WV">West Virginia</asp:ListItem>
<asp:ListItem Value="WI">Wisconsin</asp:ListItem>
<asp:ListItem Value="WY">Wyoming</asp:ListItem>

</asp:dropdownlist>

</EditItemTemplate>

<InsertItemTemplate>
<asp:DropDownList ID="state" AutoPostBack="true" DataTextField="state" DataValueField="state" runat="server"/>

</InsertItemTemplate>
<ItemStyle Wrap="False" />

</asp:TemplateField>
<asp:BoundField DataField="state" HeaderText="state" SortExpression="state" />

<asp:BoundField DataField="postalcode" HeaderText="Postal Code" SortExpression="postalcode" />
<asp:BoundField DataField="phone" HeaderText="Phone" SortExpression="phone" />
<asp:BoundField DataField="fax" HeaderText="Fax" ReadOnly="True" SortExpression="fax" />
<asp:BoundField DataField="email" HeaderText="Email" SortExpression="email" />
<asp:BoundField DataField="hoursofoperation" HeaderText="Hours Of Operation" SortExpression="hoursofoperation" />
<asp:BoundField DataField="description" HeaderText="Description" SortExpression="description" />
<asp:BoundField DataField="image1" HeaderText="Image1" SortExpression="Image1" />
<asp:BoundField DataField="image2" HeaderText="Image2" SortExpression="Image2" />
<asp:BoundField DataField="image3" HeaderText="Image3" SortExpression="Image3" />
<asp:BoundField DataField="image4" HeaderText="Image4" SortExpression="Image4" />


<asp:TemplateField HeaderText="CategoryA">
<EditItemTemplate>

<asp:DropDownList ID="DropDownListCategoryA" DataSourceID="SqlDataSource5" AutoPostBack="true"
DataTextField="Categoryname" runat="server" />
<asp:SqlDataSource ID="SqlDataSource5" runat="server" SelectCommand="SELECT DISTINCT [categoryname] FROM [tbl_category]"
ConnectionString="<%$ ConnectionStrings:connstr %>" />

</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownListCategoryA" DataSourceID="SqlDataSource6" AutoPostBack="true"
DataTextField="Categoryname" runat="server" />
<asp:SqlDataSource ID="SqlDataSource6" runat="server" SelectCommand="SELECT DISTINCT [categoryname] FROM [tbl_category]"
ConnectionString="<%$ ConnectionStrings:connstr %>" />
</InsertItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="CategoryB">
<EditItemTemplate>

<asp:DropDownList ID="DropDownListCategoryB" DataSourceID="SqlDataSource7" AutoPostBack="true"
DataTextField="Categoryname" runat="server" />
<asp:SqlDataSource ID="SqlDataSource7" runat="server" SelectCommand="SELECT DISTINCT [categoryname] FROM [tbl_category]"
ConnectionString="<%$ ConnectionStrings:connstr %>" />

</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownListCategoryB" DataSourceID="SqlDataSource8" AutoPostBack="true"
DataTextField="Categoryname" runat="server" />
<asp:SqlDataSource ID="SqlDataSource8" runat="server" SelectCommand="SELECT DISTINCT [categoryname] FROM [tbl_category]"
ConnectionString="<%$ ConnectionStrings:connstr %>" />
</InsertItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="CategoryC">
<EditItemTemplate>

<asp:DropDownList ID="DropDownListCategoryC" DataSourceID="SqlDataSource9" AutoPostBack="true"
DataTextField="Categoryname" runat="server" />
<asp:SqlDataSource ID="SqlDataSource9" runat="server" SelectCommand="SELECT DISTINCT [categoryname] FROM [tbl_category]"
ConnectionString="<%$ ConnectionStrings:connstr %>" />

</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownListCategoryC" DataSourceID="SqlDataSource10" AutoPostBack="true"
DataTextField="Categoryname" runat="server" SelectedValue='<%# Bind("IzinSeyahat") %>' />
<asp:SqlDataSource ID="SqlDataSource10" runat="server" SelectCommand="SELECT DISTINCT [categoryname] FROM [tbl_category]"
ConnectionString="<%$ ConnectionStrings:connstr %>" />
</InsertItemTemplate>

</asp:TemplateField>



<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:connstr %>"
SelectCommand="SELECT [businessid], [businessname], [ownername], [password], [webaddress], [address], [city], [state], [postalcode], [phone] , [fax], , [hoursofoperation], [image1],[image2],[image3],[image4],[description] , [categorya] , [categoryb] ,[categoryc] FROM [tbl_memberbusiness] WHERE ([businessname] = @businessname)"
UpdateCommand="UPDATE [tbl_memberbusiness] SET [ownername] = @ownername, [password] = @password, [webaddress] = @webaddress, [address] = @address, [city] = @city, [state] = @state, [postalcode] = @postalcode, [phone] = @phone, [fax] = @fax,[email] = @email,[hoursofoperation] = @hoursofoperation ,[description]=@description , [image1]=@image1, [image2]=@image2, [image3]=@image3, [image4]=@image4, [categorya]=@categorya , [categoryb]=@categoryb , [categoryc]=@categoryc WHERE [businessname] = @businessname"
DeleteCommand="DELETE FROM [tbl_memberbusiness] WHERE [businessname] = @businessname">

<SelectParameters>
<asp:ControlParameter ControlID="dbmembers" Name="businessname" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:parameter Name="businessname" Type="String" />
<asp:parameter Name="ownername" Type="String" />
<asp:parameter Name="password" Type="String" />
<asp:parameter Name="webaddress" Type="String" />
<asp:parameter Name="address" Type="String" />
<asp:parameter Name="city" Type="String" />
<asp:parameter Name="state" Type="String" />
<asp:parameter Name="postalcode" Type="String" />
<asp:parameter Name="phone" Type="String" />
<asp:parameter Name="fax" Type="String" />
<asp:parameter Name="email" Type="string" />
<asp:parameter Name="hoursofoperation" Type="String" />
<asp:parameter Name="Image1" Type="String" />
<asp:parameter Name="Image2" Type="String" />
<asp:parameter Name="Image3" Type="String" />
<asp:parameter Name="Image4" Type="String" />

<asp:parameter Name="description" Type="String" />
<asp:parameter Name="categorya" Type="String" />
<asp:parameter Name="categoryb" Type="String" />
<asp:parameter Name="categoryc" Type="String" />


</UpdateParameters>
<DeleteParameters>
<asp:parameter Name="businessname" />
</DeleteParameters>
</asp:SqlDataSource>
</td>

</tr>
</table>
<asp:Label id="MessageLabel"
forecolor="Red"
runat="server"/>

</form>

</body>
</html>





Partial Class admin_business_viewmemberdetails
Inherits System.Web.UI.Page
Protected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs)
GridView1.DataBind()
dbMembers.DataBind()
End Sub

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
End Sub

Protected Sub GridView1_Sorted(ByVal sender As Object, ByVal a As EventArgs)

DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
End Sub

Protected Sub dbMembers_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles dbMembers.SelectedIndexChanged

DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
End Sub

Sub DetailsView1_ItemDeleting(ByVal sender As Object, ByVal e As DetailsViewDeleteEventArgs)
' Cancel the delete operation if the user attempts to delete the last
' record from the data source.
MessageLabel.Visible = False
If (DetailsView1.DataItemCount <= 1) Then
e.Cancel = True
MessageLabel.Text = "You must keep at least one store."
Else
MessageLabel.Text = "Record Deleted Succefully."
End If
End Sub


'Protected Sub gdMembers_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
' DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
'End Sub


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
MessageLabel.Visible = False
End Sub
End Class
 
Since you're posting to the JavaScript forum, why not show us some actual client-side JavaScript code, rather than completely useless .Net code?

Actually asking a question might well be a good start (and good manners, if nothing else), too, as right now, we've nothing to go on.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top