so i have learned some basics through basic struggle in asp.net C# and help of forums. it seems though, in my particular issue, i take one step forward and two steps back. i want to create a basic invoice form. header information such as company, etc. in
the top part of the form. details in a list view so i can enter quantities, part numbers, dollar amounts. i can pass values from top/header of form to list view. i can also create a list view of what i want through a sql data source which ID of list view equals
ID of one of the header text boxes. but i can't put the two together. i can't pass values from header portion to list view and also have the data source from sql (get the 2 data source error). so then i think i can just do a manual insert of text boxes (header)
and columns of list view (detail) but can't figure that out.
so basically trying to see if there is a solution. pass values from data table to list view AND have another data source? manual insert statement instead of the insert template of list view that i can grab values from text boxes outside of list view and
also grab values of columns of list view?
or is there just such a more simple way that i can forget what i have spent two weeks on; abandon those thoughts, and start anew with something else? frustrated. something i can't devote all my time to but it is a requirement i need completed in near future.
can't use outside software or solutions other than asp.net/C#. any turn in the right direction would be great. thanks.
There is no reason why you can't have two data bound controls on a page where one is a header and the other, details of some sort.
osupratt1234
so basically trying to see if there is a solution. pass values from data table to list view AND have another data source?
You have total control over retrieving data sets an can have as many data bound controls on a page as you like.
Can you explain the problem you are having specifically. Are you having a problem using point and click features like the Sql Data source? Writing queries?
ideally i want a text box value (actually multiple text box values) to pass to the list view. this is a primary key of the header and a foreign key of the details or list view. i would like to have the list view behave like the insert template and show as
many rows as the end user enters or creates. then of course have all of this details info be inserted into the back-end SQL table. how do i create an insert statement to where i grab the text box values from header part and also column/row data out of list
view? the foreign key is again auto-populated in list view but should also be part of the insert template and insert statement and i can't figure it out. the way i am currently passing this value is from data table:
Maybe easier way to explain this is i want list view values to be inserted into back-end SQL database. simple example would be three columns in list view. 1st column would be auto-populated from text box on the form which i'll call header section. the 2nd
and 3rd column of the list view would come from a SQL database query. it would have a WHERE clause to where the text box value which is also column 1 of the list view are equal. 1st column auto-populated and 2nd and 3rd would be data entry by end-user. there
would be an insert button and add button at end of row. enter data click insert then add if there is another row to enter data for. pretty simple. i can auto-populate the 1st text box fine but can't get the rest of what should be normal to work.
1st column would be auto-populated from text box on the form which i'll call header section. the 2nd and 3rd column of the list view would come from a SQL database query. it would have a WHERE clause to where the text box value which is also column 1 of the
list view are equal. 1st column auto-populated and 2nd and 3rd would be data entry by end-user. there would be an insert button and add button at end of row. enter data click insert then add if there is another row to enter data for. pretty simple. i can auto-populate
the 1st text box fine but can't get the rest of what should be normal to work.
According to your description, I suggest you could bind the listview datasouce in the code-behind.
You could create a datatable and store the datatble in the viewstate when the page first loaded.
In the add button click event, you could select the database and add new row to the viewstate datatable and rebind the listview.
Member
6 Points
47 Posts
Easy invoice form
May 06, 2018 04:39 PM|osupratt1234|LINK
so i have learned some basics through basic struggle in asp.net C# and help of forums. it seems though, in my particular issue, i take one step forward and two steps back. i want to create a basic invoice form. header information such as company, etc. in the top part of the form. details in a list view so i can enter quantities, part numbers, dollar amounts. i can pass values from top/header of form to list view. i can also create a list view of what i want through a sql data source which ID of list view equals ID of one of the header text boxes. but i can't put the two together. i can't pass values from header portion to list view and also have the data source from sql (get the 2 data source error). so then i think i can just do a manual insert of text boxes (header) and columns of list view (detail) but can't figure that out.
so basically trying to see if there is a solution. pass values from data table to list view AND have another data source? manual insert statement instead of the insert template of list view that i can grab values from text boxes outside of list view and also grab values of columns of list view?
or is there just such a more simple way that i can forget what i have spent two weeks on; abandon those thoughts, and start anew with something else? frustrated. something i can't devote all my time to but it is a requirement i need completed in near future. can't use outside software or solutions other than asp.net/C#. any turn in the right direction would be great. thanks.
All-Star
37171 Points
15019 Posts
Re: Easy invoice form
May 06, 2018 05:09 PM|mgebhard|LINK
There is no reason why you can't have two data bound controls on a page where one is a header and the other, details of some sort.
You have total control over retrieving data sets an can have as many data bound controls on a page as you like.
Can you explain the problem you are having specifically. Are you having a problem using point and click features like the Sql Data source? Writing queries?
Member
6 Points
47 Posts
Re: Easy invoice form
May 06, 2018 11:54 PM|osupratt1234|LINK
ideally i want a text box value (actually multiple text box values) to pass to the list view. this is a primary key of the header and a foreign key of the details or list view. i would like to have the list view behave like the insert template and show as many rows as the end user enters or creates. then of course have all of this details info be inserted into the back-end SQL table. how do i create an insert statement to where i grab the text box values from header part and also column/row data out of list view? the foreign key is again auto-populated in list view but should also be part of the insert template and insert statement and i can't figure it out. the way i am currently passing this value is from data table:
DataTable dt = new DataTable();
dt.Columns.Add("txtFieldTicketDate", typeof(DateTime));
dt.Columns.Add("txtFieldTicketNumber", typeof(string));
dt.Columns.Add("txtSONumber", typeof(int));
DataRow r = dt.NewRow();
r["txtFieldTicketDate"] = txtFieldTicketDate.Text;
r["txtFieldTicketNumber"] = txtFieldTicketNumber.Text;
r["txtSONumber"] = txtSONumber.Text;
dt.Rows.Add(r);
ListView1.DataSource = dt;
ListView1.DataBind();
Member
6 Points
47 Posts
Re: Easy invoice form
May 07, 2018 12:05 AM|osupratt1234|LINK
Maybe easier way to explain this is i want list view values to be inserted into back-end SQL database. simple example would be three columns in list view. 1st column would be auto-populated from text box on the form which i'll call header section. the 2nd and 3rd column of the list view would come from a SQL database query. it would have a WHERE clause to where the text box value which is also column 1 of the list view are equal. 1st column auto-populated and 2nd and 3rd would be data entry by end-user. there would be an insert button and add button at end of row. enter data click insert then add if there is another row to enter data for. pretty simple. i can auto-populate the 1st text box fine but can't get the rest of what should be normal to work.
Star
8931 Points
2723 Posts
Re: Easy invoice form
May 14, 2018 08:53 AM|Brando ZWZ|LINK
Hi osupratt1234,
According to your description, I suggest you could bind the listview datasouce in the code-behind.
You could create a datatable and store the datatble in the viewstate when the page first loaded.
In the add button click event, you could select the database and add new row to the viewstate datatable and rebind the listview.
More details, you could refer to below example:
ASPX:
Code-behind:
Result:
Best Regards,
Brando