|
|
<a href="javascript:history.back()">Go To Previous Page</a>
Regards
John
|
|
|
|
|
|
Hello All,.
I am facing a Problem Here.
I Have been trying to do this since 2 days.
Note : I am working on ASP.NET with C# as code behind
Assume that I have a the Following Database Tables from Northwind DataBase
1) Products
2) category
The Category table Contains Category ID and categoryName
The Products Table Contains ProductName , categoryID
I have a GridView whose data source is the ProductTable
I have a DropDownList whose data Source is the Category Table
and the dropdownlist Should only display the Category Name
Based on the Selected Category Name from the drop down list, the products Table should display on the GridView control which I added on the aspx page earlier
But the twist here is
In order to get the ProductNames from the Products Table , I have to pass the CategoryID only to the method that has the SQL Query.. GetProductsBycategoryID()
But I am only displaying the Category Names on the Drop Down List
How can I Relate the Names to their corresponding IDs and then pass the category ID to the GetProductsbycategoryID() function..
Please let me know on this.
This is the code I am trying to work on...
It is very dissorganised as I am trying different things
If this sample works for me , I can include this functionality in my project,.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using NorthwindTableAdapters;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ProductsTableAdapter productsAdapter = new ProductsTableAdapter();
CategoriesTableAdapter categoryAdapter = new CategoriesTableAdapter();
// ddl_Category.DataSource = categoryAdapter.GetCategories();
//ddl_Category.DataTextField = "CategoryName";
//ddl_Category.DataValueField = "CategoryID";
//ddl_Category.DataBind();
GridView1.DataSource = productsAdapter.GetProducts();
GridView1.DataBind();
ddl_Category.Items.Insert(0,"PleaseSelectACategory");
ddl_Category.Items.Insert(1, "Some1");
ddl_Category.Items.Insert(2, "Some2");
ddl_Category.Items.Insert(3, "Som3");
ddl_Category.Items.Insert(0, "PleaseSelectACategory");
ddl_Category.SelectedIndex = 0;
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void ddl_Category_SelectedIndexChanged(object sender, EventArgs e)
{
////ProductsTableAdapter productsAdapter = new ProductsTableAdapter();
//////int catID = ddl_Category.SelectedIndex;
////string somesome = ddl_Category.SelectedValue.ToString();
////int catID2 = Int32.Parse(somesome);
////GridView1.DataSource = productsAdapter.GetProductsByCategoryID(catID2);
////GridView1.DataBind();
}
protected void ddl_Category_SelectedTextChanged(object sender, EventArgs e)
{
}
}
Thanks a lot,
Nikhil Pagidala
Happy Programming!
Regards,
Nikhil Pagidala
|
|
|
|
|
Nikhil Pagidala wrote: The Category table Contains Category ID and categoryName
Nikhil Pagidala wrote: ddl_Category.Items.Insert(0,"PleaseSelectACategory");
ddl_Category.Items.Insert(1, "Some1");
ddl_Category.Items.Insert(2, "Some2");
ddl_Category.Items.Insert(3, "Som3");
ddl_Category.Items.Insert(0, "PleaseSelectACategory");
ddl_Category.SelectedIndex = 0;
Didn't you write a method that will fetch the data from the category table and bind to the dropdownlist. something like.... GetAllCategory()
Nikhil Pagidala wrote: ddl_Category.SelectedIndex = 0;
you don't have to explicitly write a line to set the SelectedIndex property of DropDownList to Zero(0). it set's it by Default.
Nikhil Pagidala wrote: How can I Relate the Names to their corresponding IDs and then pass the category ID to the GetProductsbycategoryID() function..
set the AutopostBack property of the dropdown list to True
Fetch the Data from the Category table and Bind the CategoryID and CategoryName feild to the DataValueField and DataTextField property of the DropDownList control. try something like this....
DataSet LocalDataSet = new DataSet(); <br />
LocalDataSet = MobjDAL.GetALLCategory(); <br />
ddlCategory.DataValueField = "CategoryID"; <br />
ddlCategory.DataTextField = "CategoryName"; <br />
ddlCategory.DataSource = LocalDataSet; <br />
ddlCategory.DataBind();
then in the selectedIndexChanged Event of the DropDownList try something like this to show the related Data in the GridView...
DataSet LocalDataSet = new DataSet();<br />
LocalDataSet =productsAdapter.GetProductsByCategoryID(ddlCategory.SelectedValue);<br />
GridView1.DataSource = LocalDataSet; <br />
GridView1.DataBind();
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
|
GridView is only control that displays data.
Datasource connect to your SQL Server. When you Bind datasource to a GridView, You will connect GridView to database. If you don't use Datasource, you would need to write a code to read from database to GridView. I am doing a certan project, that require more control, so i am doing it manualy.
|
|
|
|
|
ss.mmm wrote: why to use datasource to gridview?Can you please explain?
To tell the GirdView what Data to dsiplay and From where(Source) the Data has to be fetched."
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Which is the best way to store a dataset over a page?
Session, Cache or Viewstate?
Thanks
|
|
|
|
|
ss.mmm wrote: Which is the best way to store a dataset over a page?
Session, Cache or Viewstate?
It depends on how you want to access the dataset.
1 - Session : Can be used if you want to access your dataset in all the pages and it should be user specific. Not recommended if your dataset is huge.
2 - Cache : It will be cached. And if same dataset will be accessible for all users.
3 - ViewState : If you want to get access to the dataset only on single page. Stored as hidden fields in the page. You class should be serializable to keep it in viewstate. I don't think that dataset is serializable.
Hope it helps
--If this post helps you, please vote for it.
|
|
|
|
|
Session (User Level Access)
Storing the Dataset in the session is not at all a good idea. The reason is --- Say you have a dataset containg around 1000 records and you are storing it in a Session Object. Let us consider some 1000 user's logged-in and having access to the same set of Records. Can you Image the load on the Server? In this case, Response from the server will be tramendously slow and User's will experience Response Time out problem for each page Request. Instead of storing it in a session object, we can go and query the Database everytime.
Viewstate (Page Level Access)
when we store anything in the Viewstate, a hidden field will be created in the HTML. Let us take the same example -- say you have a dataset containing arund 1000 records and you are Assigning it to the Viewsate. Run this and view the source of the page. This will increase the page size dramatically. When the Page size is larger It will take much longer time to execute and Load.
ViewState is only used to save the values for the page level access which should be maintained after post backs. It Is recommended and Ideal only to save small values.
Caching (Application Level Access)
If you plan to store a large dataset then Data Caching is the Best way. A copy of Dataset can be cached in the server and whenever any user want to access the same set of Data then it can be fetched from the Cache instead of querying the Database everytime. Having a single copy of Cached Data for all User's doesn't put's much load on the server and This will radically increase the perfromance of the application.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Hi,
Did anybody have experience the same issue? I am using SQLserver session state with trusted connection as shown below:
sessionState mode="SQLServer" sqlConnectionString="data source=MydatabaseServername;integrated security=SSPI" cookieless="false" timeout="5"
and form authentication
<authentication mode="Forms">
<forms loginurl="Login.aspx" name=".ASPXFORMSAUTH">
After I login, I wait until sesssion timeout reachs, like 10 minutes, then click on other pages, I still can access. But if I wait for a much longer time, like 30 minutes, then click on other pages, I was logged out. It looks like the session timeout is still using default value 20 minutes, even though I set it as 5 minutes. But I couldn't confirm it. Does anyone have any ideas on it?
Thanks in advance!
|
|
|
|
|
vicky457 wrote: I was logged out. It looks like the session timeout is still using default value 20 minutes, even though I set it as 5 minutes. But I couldn't confirm it. Does anyone have any ideas on it?
Not clearly, but try with setting the session timeout in Session_Start event on global.asax file.
|
|
|
|
|
I want to create a namespace. I don't know how to do it. I add a class in
my project. Should I add keyword namespace myNmaspace to it. or how can I do
it.
I want three files
myNmaespace.fileA
myNmaespace.fileB
myNmaespace.fileC
Where fileA.ca, fileB.cs,fileC.cs are my Classfiles.
seema
|
|
|
|
|
yp.
it like this:
namespace myNmaspace
{
}
And of course you can use same namespace on more than one file. You have to repeat it for every file you want to do it.
|
|
|
|
|
Hi there...
I'm facing an issue very annoying. I'm developing an ERP in ASP.net using 3 tier technic. The ERP has a lot of modules, so we create 3 solutions for every module. Business Logic Layer, Data Access Layer and Presentation Layer. We cannot create 1 solution for each module because the modules are connected . So is a pain in the ass when I have to debug a layer that isn't the presentation layer! Then I ask:
- Is there a way to debug DLL solutions?
- if not, how is the best way to test my application?
Thanks a lot!
|
|
|
|
|
I don't get it, why do you use 3 solution.
you could use 1 solution with 3 projects and when you have specificied a Reference, you could use break point in different project.
If that isn't what you wanted, then open as many instances of visual studio and load each solution, then in each instances, go to debug menu and "attach process": WebDev.WebServer.EXE. And it will stop on breakpoint in instances of your visual studio.
I hope you understand, what i am trying to type.
|
|
|
|
|
I did a little search, you can use any instances for debugging, but only one instances can be attached to WebDev.WebServer.exe.
I still suggesting to use only one solution, with multiple projects. Thus you will have debugging access to the project, that builds a Dll.
|
|
|
|
|
Hi You cannot debug a dll. Instead try to find the Project FIles for that dll (source code) and then attach the source code to your existing project, Delete the existing dlls from the references and then refer the added project to your existing project.
Start Debugging Now
Note : dll is a very secured format which has all the underlying logic of the application. dlls are created to be secure and to be used without having access to the source code. You cannot get into the source code of the dll.
HAppy Coding
Happy Programming!
Regards,
Nikhil Pagidala
|
|
|
|
|
Hi
i am currently doing a project on miedical diagnosis tt require the application to be able to perform some inferences based on the user input.
however i am not sure how i can go abt doing it?
is neural network the right path to go?
if so, how/where to i start from
is there any free neural network s/w available , so tt i can link up with my website to perform the inferences?
|
|
|
|
|
HI, i am have this grid view, and i have a ds binding a repeater. i want to filter the select command depending on the seleccion in the gridview, i have this code, but i can't make work right.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="EventId"<br />
DataSourceID="SqlDataSource1" SelectedIndex="1"><br />
<Columns><br />
<asp:CommandField ShowSelectButton="True" /><br />
<asp:BoundField DataField="EventId" HeaderText="EventId" InsertVisible="False" ReadOnly="True"<br />
SortExpression="EventId" /><br />
<asp:BoundField DataField="EventName" HeaderText="EventName" SortExpression="EventName" /><br />
<asp:BoundField DataField="EvenThun" HeaderText="EvenThun" SortExpression="EvenThun" /><br />
</Columns><br />
</asp:GridView><br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:vpx_newConnectionString %>"<br />
SelectCommand="SELECT * FROM [Events]"></asp:SqlDataSource> <br />
<br />
Sub BindData()<br />
'Read sample item info from XML document into a DataSet<br />
Dim cnn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("vpx_newConnectionString").ToString)<br />
cnn.Open()<br />
Dim cmd As SqlDataAdapter = New SqlDataAdapter("select * from mediaphotos Where EventID =" & GridView1.SelectedValue, cnn)<br />
<br />
Dim ds As New DataSet()<br />
cmd.Fill(ds)<br />
<br />
' Populate the repeater control with the Items DataSet<br />
Dim dsPaged As New PagedDataSource()<br />
dsPaged.DataSource = ds.Tables(0).DefaultView<br />
dsPaged.AllowPaging = True<br />
dsPaged.PageSize = 5<br />
<br />
dsPaged.CurrentPageIndex = CurrentPage<br />
<br />
'Disable Prev or Next buttons if necessary<br />
cmdPrev.Enabled = Not dsPaged.IsFirstPage<br />
cmdNext.Enabled = Not dsPaged.IsLastPage<br />
<br />
rptParts.DataSource = dsPaged<br />
rptParts.DataBind()
can someone help me here, what i am doing wrong
|
|
|
|
|
Hi guys,
How can i add numbering with a checkboxlist control that is depending on the total number of items checboxlist has in it. For instance,
1[]Book1
2[]Book2
3[]Book3
By default I can add items to the checklist but i there is no way to display numbers on the left side.
I would appreciate anyinput.Thanks in advance.
|
|
|
|
|
netJP12L wrote: i there is no way to display numbers on the left side.
No there is no predefined way d\to do this. You can do this by using DataGrid/GridView instead of Checkbox list. In datagrid/gridview first bound columns should be index columns which shows current row index. Next columns will be your checkbox. To get the checked status, loop through entire grid and find the checkboxes.
|
|
|
|
|
Hi,
I have a datagrid,which has template columns and bound columns <b>dynamically</b> built. Now i need to have two header rows. The first header row spanning over certain number of columns( should be dynamic).
Both the header row text will be from database.
Want something like this.
1.1 & 2.2 are spanning over 4(Not fixed) columns(A R S X).
Blue, red,green ,yellow is in the first column. There are 9 column and 2 rows in the below shown example. I need 2 headers and number of columns vary.
1.1 1.2
A R S X A R S X
Blue
RED
GREEN
Yellow
I would like to do this with a datagrid, but if you have any other suggestion to achieve this, let me know.
Thanks,
kavi
|
|
|
|
|
kavishan wrote: I would like to do this with a datagrid,
Use only template columns and create a table which looks like your requirement.
|
|
|
|