Forms Data Controls :: CheckboxList And Sql Data Source Advanced?
Mar 30, 2010
I am attempting to create a list of top ? results of a specified column(s) of a specified table on a specified database. Sounds tricky, huh? I am attempting to create a key creator for a raw data table. So far I have a list of all raw column names in the table displaying on a checkboxlist control. On the page there is a checkboxlist control on the left. A drop down menu in the middle and a gridview (hidden until the checkboxlist selects an item) on the far right. Once the user selects an item on the checkboxlist control and also selects an item (or leaves it as default) in the drop down menu (values consist of : 1, 2, 3, 4, 5, ect.) the gridview will appear and display the top (value in the drop down menu) results of the selected column in the checkboxlist control (would be nice to allow the user to select multiple items and have the gridview grow as more columns are selected and shrink as they are deselected). I am having trouble figuring this out. So far I have attempted to write a dynamic sql stored procedure, add parameters to the sqldatasource and change the value at runtime, and now I am reaching out to the ASP.Net community.
[Code]....
View 1 Replies
Similar Messages:
Mar 29, 2010
I am tring to build a page with advanced search options. Here is my code am I on the right path. What I wnat this to do is if you put something in any one of the textboxes it will filter by that column.
<%@ Page language="C#" masterpagefile="MainContent.master" title="Electrical Storage" EnableEventValidation="false" %>
<asp:Content id="Content1" runat="server" contentplaceholderid="Content">
<div id="Rightside">
<h2>Search Electrical Storage
</h2>
<li><a href="EStorageResultsAll.aspx">View All Files</a></li>
<li>Specify Projects to View</li>
<form>
<table style="width: 500px">
<tr><td></td>
<td>Company ID</td>
<td><asp:TextBox runat="server" id="CoID" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>Project Class</td>
<td><asp:TextBox runat="server" id="ProjClass" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>Project</td>
<td><asp:TextBox runat="server" id="Proj" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>File Name</td>
<td><asp:TextBox runat="server" id="FileName" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>File Number</td>
<td><asp:TextBox runat="server" id="FileNumber" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>File Additional Info</td>
<td><asp:TextBox runat="server" id="FileAdd" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td>Box Number</td>
<td><asp:TextBox runat="server" id="BoxNumber" Width="200px"></asp:TextBox></td>
</tr>
<tr><td></td>
<td><asp:Button runat="server" Text="Search" id="Button1"></asp:Button></td>
<td></td>
</tr>
</table>
<hr />
<asp:GridView id="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" DataSourceID="AccessDataSource1" ForeColor="Black" Width="820px" AllowSorting="True">
<RowStyle BackColor="White" />
<Columns>
<asp:boundfield DataField="CoID" HeaderText="Co ID" SortExpression="CoID">
</asp:boundfield>
<asp:boundfield DataField="ProjClass" HeaderText="Project Class" SortExpression="ProjClass">
</asp:boundfield>
<asp:boundfield DataField="Project" HeaderText="Project" SortExpression="Project">
</asp:boundfield>
<asp:boundfield DataField="FileName" HeaderText="File Name" SortExpression="FileName">
</asp:boundfield>
<asp:boundfield DataField="FileAddInfo" HeaderText="File Add Info" SortExpression="FileAddInfo">
</asp:boundfield>
<asp:boundfield DataField="FileNumber" HeaderText="File Number" SortExpression="FileNumber">
</asp:boundfield>
<asp:boundfield DataField="BoxNumber" HeaderText="Box Number" SortExpression="BoxNumber">
</asp:boundfield>
<asp:boundfield DataField="Location" HeaderText="Location" SortExpression="Location">
</asp:boundfield>
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000066" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="\Elec1DATABASEStorageElectricalFilesBook.mdb" SelectCommand="SELECT [CoID], [ProjClass], [Project], [FileName], [FileAddInfo],
[FileNumber], [BoxNumber], [Location] FROM [FilesWithLocation] WHERE (([CoID] LIKE '%' + ? + '%') OR ([ProjClass] LIKE '%' + ? + '%') OR ([Project] LIKE '%' + ? + '%') OR ([FileName] LIKE '%' + ? + '%') OR ([FileAddInfo] LIKE '%' + ? + '%') OR ([FileNumber]
LIKE '%' + ? + '%') OR ([BoxNumber] LIKE '%' + ? + '%'))">
<SelectParameters>
<asp:controlparameter ControlID="CoID" Name="CoID" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="ProjClass" Name="ProjClass" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="Proj" Name="Project" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="FileName" Name="FileName" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="FileAdd" Name="FileAddInfo" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="FileNumber" Name="FileNumber" PropertyName="Text" Type="String" />
<asp:controlparameter ControlID="BoxNumber" Name="BoxNumber" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
</form>
</div>
</asp:Content>
<asp:Content id="Content2" runat="server" contentplaceholderid="head">
<style type="text/css">
</style>
</asp:Content>
View 2 Replies
May 7, 2015
I need to charge my checkboxlist1 from database, eg load fruits and vegetables. When selecting fruits, new filter based on the previous selection in my checkboxlist2. for specific search.
View 1 Replies
Jun 1, 2010
in my button4 click event, i want to insert checboxlist items to data table. first i want to delete all of the exisiting and then insert again.
my code is below but it is not working if you could explain anyone ?
in page load I have written code so that existing checkbox items are selected.
[code]...
View 5 Replies
Feb 24, 2011
I am somewhat new at C# so forgive me if I have something listed wrong. This is what I got:
I am working on a school project designing a car dealership website. I have an inventory list that allows you to edit any car in the inventory. When you click on the edit button it takes you to the edit page and populates the controls with selections from the database. I have an options table that stores the VehicleID and Option ID. When the page loads it fills all the DropDownLists for the vehicle info with the data and selects the correct item according to the database selection but the CheckBoxList does not select the items that are on the Options table. I checked the query in SSMS and it returns the correct data. I have stepped through the method and it works till the "(currentCheckBox != null) if statement. It doesn't throw any errors but it also doesn't select items when the page renders.
I thought it might have been something with the page life cycle since databound controls don't render until the end but the DropDown's I have fill and selects the correct item according to the database.
View 2 Replies
May 6, 2010
Scenario : I want to add data from database to checklistbox on page_load and checked data should be stored in other table.I want to bind data to checklistbox like a gridview, i m trying but i m not able to.
View 2 Replies
Oct 14, 2010
I can insert a checkboxlist selected value as comma delimited string into the database. But I have hard time to reload it in formview edit mode. I added a hidden label to retrieve the comma delimited string and try to use checkboxlist databound event, but it doesn't work. I don't know what problem is in my code.
[Code]....
[Code]....
View 7 Replies
Jun 23, 2010
I have a page where I will insert all the data into the database. The page where I'm having problems is when I select an item from the checkboxlist it only displays one item. The data which is displayed is only the one that was inserted with one selected item from the checkboxlist. The following code is the page I'm using to try to retrieve the data from the database. I am trying to do is when a user selects the first, second, or third, or fourth item. The corresponding data appears in the gridview. In my current code, the record which has one item selected appears. If the user has more than one selected it does not appear. It comes up as empty. Is there a way I can do it?
[Code]....
View 4 Replies
Nov 30, 2010
I working on a dontnetnuke module, and was wondering how can I bind a selected checkboxlist item into the databse
Now I got it like this, but this if or 'one' selected item.
But the thing I want it, that every one of them has their own Value (abPermission.TabID, TabPermission.PermissionID, TabPermission.AllowAccess, TabPermission.UserID) (tabhome = 6,6,6,6) (tabsupp = 7,7,7,7)
If I select 'one' or 'multiple' they values will be inserted into the database
[Code]....
View 1 Replies
Mar 30, 2011
This is my code and i am only able to edit the one data under the category school.But what i nd is to edit the other categories like the name,email...etc..how do i modify my code in the update command.Another thing is to delete the data how do i do that?
[Code]....
View 6 Replies
Jun 1, 2010
I'm new to ASP.net 3.5 and trying to create a test site so I can figure out how to use it in the real world. I have created a FormView (Formview1) based on a Client table using Linq Data Sources. The page includes a DropDownList to lookup Clients. I have added a list option (<asp:ListOption value="" Text="(Select Client)" and set AppendDataBoundItems=true so my added option is displayed. I decided to try to use Formview with only the Edit and Insert Modes, and I have set the Default Mode = Insert. When you open the page, a blank Client record is displayed.
The Client record contains serveral lookup fields and they have drop down lists for each. When I select a client from the Client DropDownList, is get the following message 'ddlClientType' has a SelectedValue which is invalid because it does not exist in the list of items I had this problem before and decided the best way to handle this (in the interim) was to turn off foreign key constraints for each of the lookup fields (e.g. ClientType) in SQL Server. That worked for 2-3 days. Now the problem has started again.
When I develop in other applications, I would simply create a lookup data source based on a Union Query with the actual data and a blank record. How can you do this using Linq DataSources. Can you get access and modify the queries?
View 1 Replies
Jan 1, 2011
I've been using the Item Inserted event for my data controls, such as details view. I'm wondering if there are advantages to doing this with the data sources instead of the data control. There is a lot of overlap in the events provided by these two types of controls. Are there advantages to using the events raised by the data source instead of the ones raised by the data control itself. Should I be using the events raised by the data source instead of the control used to enter the data?
View 2 Replies
Mar 5, 2010
I want to select more than one item of CheckBoxList and then search those item from database and then select them.
I wrote this code but it can only select one item at a time.
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected == true)
{
var sql = from x in db.names
where x.name1 == CheckBoxList1.Items[i].ToString()
select x;
GridView1.DataSource = sql.ToList();
GridView1.DataBind();
}
}
}
View 4 Replies
Jan 4, 2010
I'm using update panel in the master page. Half of my web page will retreive the data from the database in dynamic. As, my update panel is in master page(with ajax loader), it is taking much time for every event. Is there any other advanced method to get the data from the database instead of using update panel.
View 2 Replies
Mar 30, 2010
I have a GridView or DetailsView and its bound to a CslaDataSource.I noticed that the "Object_Select()" event is fired automatically with every time the page is loaded or refreshed.How I can perfrom mnaual biding between the DetailsView Control and CslaDataSource ?I want to control binding via code using the DetailsView.DataBind() method in certain cases only.
View 4 Replies
Apr 30, 2010
I'm creating a page that allows the user to create a new object that will later be stored in the database. The problem is that the design of ASP.NET data controls seems to insist upon only working with pre-existing data that has been stored in a database (or XML, etc...).
I'm basically trying to get the user to compose a list of items and specify a quantity for each item. I could do this by generating table rows but the rows are lost at each postback. The data view controls seem to be designed only to be bound to a data source but until the list is complete, the data can only be in memory.
What control is appropriate for this and how can I achieve this with that control?
View 4 Replies
Aug 6, 2010
I am trying to create FormView that has details aboout author. But some details about his books like pubdate, title resides in some other table. In the source page:
<asp:Label id"AuthorName" Text='<% #Bind("au_fname")%>' runat="server/>
but this field has to be obtained from other table:
<asp:Label id="AuthorTitle" Text='<% #Bind("title")%>' runat="server"/>
the title resides in titleauthor table, can we use two connections(author, titlesauthor) simultaneously.
View 11 Replies
May 27, 2010
Am using the following 2 events for child grid.
1. RowDataBound
2. RowEditing
I enable AutoGenerateEditButton = "true", which can show me edit button in the child grid. Also i have tried to use the event rowediting which can return e.NewEditIndex too. for the master i use sqlDatasource design time. for the child grid am confusing how to do the edit/delete/add.
following link good enuf for master grid
[URL]
for child grid datasource if am not mistaken, guess need to assign the datasource during runtime. am not sure how to do this?
Following is the link for my so far trial
[URL]
[Code]....
[Code]....
View 4 Replies
Jun 15, 2010
I have extended GridView in order to have consistent look & feel, paging and sorting. However, when the page is first time loaded, the select method is getting called twice. It works fine when i move between pages in pagination.
Note, i am using Asp.net 2.0.
View 2 Replies
Sep 27, 2010
i wanted to retrieve things from the data base and perform mathmatical operations on it then post it to the user, so i was told to use the bullited list and bind it to the object dataSource
how to perform such thing??
View 1 Replies
Apr 1, 2011
I have a gridview with daatsource from MembershipUserCollection. When my collection doesn't contain any records the gridview just disappears. I want to display the empty gridview indicating no records exist rather than the grid just become invisible.
How to make gridview always visible ?
View 4 Replies
May 22, 2010
I have got the following code:
[Code]....
This should give me the friends of the user currently logged in in the Repeater, but gives me an exception on the runtime that an instance needs to be initialized, can you please suggest a solution...
Also, what should be the value of the NavigateUrl property of a Hyperlink in an ItemTemplate if the url is:
"http://domain.com/viewprofile.aspx?id=" + 'THE UserID property of the current element in the list'
View 3 Replies
Feb 10, 2011
How to edit gridview row when not using sqldatasource and autogeneratecolumn property is set to true.I have a dropdownlist where table is selected on which gridview is populated (through sp from oracle) which is working but edit command is not working.Do i have to generate template myself or what ever solution?
View 1 Replies
Apr 20, 2010
update the data in sqldatasource without gridview. how to do that?
View 3 Replies
Feb 13, 2011
I have a gridview and I have an edit template for one control. I have a drop down box in this edit template so that you can select a value from it and then when you hit 'Update' the value from the drop down box is committed to the updated record. Unfortunately when I do hit the update button I get a fault that the "Status" field cannot be null.
Here is the code that picks the value from the drop down value and assigns it to the new values list:
[Code]....
View 4 Replies