
rangerstud620
Avatar/Signature-
Posts
27 -
Joined
-
Last visited
rangerstud620's Achievements
Newbie (1/14)
0
Reputation
-
I'm using a DetailsView to update a SQL database. One row in the DetailsView contains a dropdownlist with a value = Heading and text = Headname. When the database is updated though, the Heading and Headname fields are both filled with the Heading value. I have separate parameters set up for each, so I can't figure out how both Heading and Headname are getting the same value. I'm sure it's something simple but I just cannot see it. Any ideas? Thanks! <asp:TemplateField HeaderText="YP Heading" SortExpression="HEADNAME"> <EditItemTemplate> <asp:DropDownList ID="ddlHeadings" runat="server" DataSourceID="dsHeadings" DataTextField="HEADNAME" DataValueField="HEADING" Width="650px" SelectedValue='<%# Bind("HEADING","{0}") %>' EnableTheming="True"> </asp:DropDownList><asp:SqlDataSource ID="dsHeadings" runat="server" ConnectionString="<%$ ConnectionStrings:TestCompany %>" SelectCommand="SELECT [HEADING], [HEADNAME] FROM [HEADINGS] ORDER BY [HEADING]"> </asp:SqlDataSource> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("HEADNAME") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:SqlDataSource ID="dsCompany" runat="server" ConnectionString="<%$ ConnectionStrings:TestCompany %>" SelectCommand="SELECT * FROM [NewReport] WHERE ([sORTCODE] = @SORTCODE) ORDER BY [LINENUMBER]" UpdateCommand="UPDATE NewReport SET HEADING = @Heading, HEADNAME = @Headname, CHANGES = @Changes, COMMENTS = @Comments WHERE SORTCODE = @Sortcode"> <SelectParameters> <asp:ControlParameter ControlID="lstCompany" Name="SORTCODE" PropertyName="SelectedValue" /> </SelectParameters> <UpdateParameters> <asp:ControlParameter ControlID="DetailsView1$ddlHeadings" Name="Headname" PropertyName="text" Type="string" /> <asp:Parameter Name="Heading" Type="string" /> <asp:Parameter Name="Changes" Type="string" /> <asp:Parameter Name="Comments" Type="string" /> <asp:Parameter Name="Sortcode" Type="string" /> </UpdateParameters> </asp:SqlDataSource>
-
Never mind...figured it out.
-
I've got a datagrid with a EditCommandColumn. For certain rows I may need to disable or hide the Edit button. How can this be done? Thanks!
-
Thanks, that took care of the problem. But I'm still confused why it didn't work with the "?". I've used ?'s before and have not had a problem. We actually just got done doing some work on our SQL Server that involved moving/changing some SQL db's. Before that, this code (with the ?) worked fine, so that's why I thought I had a setting wrong in the db.
-
I'm trying to update a SQL db using ASP.NET but I keep getting the following error: "Line 1: Incorrect syntax near '?'. Line 1: Incorrect syntax near '?'." Here is my code: Dim di As DataListItem Dim cmd As New SqlCommand("UPDATE YPVerification SET [MEMO] = ?, [sTATUS] = ?, [DATE_VERIFIED] = ? WHERE IMG_ID = ?", objConnection) Dim param As SqlParameter Dim rbList as RadioButtonList = E.Item.FindControl("rbList") Dim CurrDate as New DateTime() CurrDate = DateTime.Now Dim strCurrDate as String = CurrDate.ToString di = E.Item cmd.CommandType = CommandType.text 'Update parameters param = cmd.Parameters.Add("?", SqlDbType.Char) param.Value = DirectCast(di.FindControl("txtMemo"), textbox).Text If rbList.Items.FindByValue("Y").Selected = True then param = cmd.Parameters.Add("?", SqlDbType.Char) param.Value = "Y" param = cmd.Parameters.Add("?", SqlDbType.Char) param.Value = strCurrDate Else param = cmd.Parameters.Add("?", SqlDbType.Char) param.Value = "N" param = cmd.Parameters.Add("?", SqlDbType.Char) param.Value = "N/A" End If param = cmd.Parameters.Add("?", SqlDbType.Int) param.value = E.Item.ItemIndex + 1 'Update database cmd.Connection.Open() cmd.ExecuteNonQuery() '***ERRORS HERE*** dataList.EditItemIndex = -1 cmd.Connection.Close() Can anyone see the problem? I keep thinking it's a problem with the database but I'm not sure.
-
fizzled, those are some interesting points that I will have to check into. Thanks!
-
I'm in the process of switching my apps from Access to SQL2000. Everything was working fine with Access but now as I'm making the switch to SQL, I'm having problems. First, when I click an item in a ListBox, the selectedindex does not change, it stays at 1. <asp:listbox ID="ListBoxMaster" runat="server" AutoPostBack="true" Rows="22" Width="300" DataValueField="LEAD_ID" DataTextField="COMPANY" OnSelectedIndexChanged="SelIndexChange" /> The following code in SelIndexChange always returns the value of 1, no matter which item in the list I select: Dim LeadID as integer = ListBoxMaster.SelectedItem.Value Second, when I pick an item from a dropdownlist, the item I select appears to be the actual selecteditem in the ddl, but when I try to update the db the value returned is the same as the original value in the db. <asp:dropdownlist ID="ddlSalesperson" runat="server" Enabled="false" Width="100" DataValueField="SALES_NUM" DataTextField="REVERSE_NAME" DataSource="<%# FillSales() %>" /> The following code always returns the original value in the database when I try to update the db. param = cmd.Parameters.Add("@Salesperson", SqlDbType.Char) param.Value = DirectCast(di.FindControl("ddlSalesperson"), dropdownlist).SelectedValue It seems none of the selectedindexchanged events are being raised. I'm lost as to what is wrong now that I'm using SQL. Any ideas what I'm doing wrong?
-
I'm having a problem controlling the width of a list box. I populate the list box from a database and it seems the width is determined by the length of the longest list item...it doesn't matter what I have the width property set to. Is there a fix to this? Thanks!!
-
Thanks for the input! I think I will try to use a query string to make it work. I think that will work better than a session variable.
-
I've got a web form with a list box on it. When I click on an item in the list box, I need to open another window and display some details about the selected item. Should I use a session variable to capture the selected item from the list box? Or is there a more efficient way to do that?
-
Thanks for the idea wayneph. I will take a look at that and see what I can come up with. I haven't done anything like this yet so we'll see how it goes :p. If anyone has any other ideas, I'm certainly open to them. Thanks for the help!!!
-
I'm tackling a rather advanced project and I'm looking for some ideas to get started. :eek: I've got a DB table that contains customer info. Each customer could have multiple records in the table that are linked by the field, "SCode." Basically I need to group all records for each customer and then display them. The display would look something like this: Customer 1 Customer 2 Customer 3 address....phone address....phone address....phone address....phone address....phone address....phone Each customer's info will need to be edited, but right now I'm just looking at getting everything displayed correctly. So first off, is it possible to display records this way? I was thinking a DataList might work? If it is possible, how would I go about getting it setup? Any help or ideas would be awesome!!!
-
Thanks kahlua001, that worked perfectly!!
-
I'm sure this is simple to do but I'm stumped. I created an image gallery using a datalist. For each image, there are 2 radiobuttons (Approve, Disapprove). The radiobutton that needs to be checked is determined by the value of a field in a database. For example, if the DB field = "Y", the Approve radiobutton should be checked. If the DB field = "N", the Disapprove radiobutton should be checked. How do I get the correct radiobutton selected? Thanks
-
I ran across something like that too. Unfortunately, I am using MS Access so my only choice is to save the filename in the database.