Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 10, 2012 05:47 AM by aoshi_kh
Apr 09, 2012 07:52 AM|LINK
i have gridview bind with 1 datasource to get all data, but now i want to add 1 more dropdown which need to get the data from other table. Did anyone have idea how to do this? in VB, thanks
Apr 09, 2012 09:00 AM|LINK
Add a new SqlDataSource (or similar) to select the data from the other table and then add a template field n your GridView to display the DropDownList with the data from the new DataSource control:
<asp:DropDownList ID="ddl" runat="server" AppendDataBoundItems="true" DataSourceID="newDataSourceId" DataTextField="id" DataValueField="name">
Apr 09, 2012 09:03 AM|LINK
cehck below link
Apr 09, 2012 09:09 AM|LINK
thanks for your suggestion, i try your way but i keep getting Could not find any attribute 'appendDataBoundItems' of element 'DropDownList' and also error when i write for new datasource??
Apr 09, 2012 09:37 AM|LINK
Right, remote the AppendDataBoundItems property:
<asp:DropDownList ID="ddl" runat="server" DataSourceID="newDataSourceId" DataTextField="id" DataValueField="name">
What other error message(s) do you get?
Apr 09, 2012 09:41 AM|LINK
now i try to create 2 set of return result in my stored procedure, but them i bind it to the dropdownlist, it keep prompt "DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'dytValue'. dytValue is the 2nd set of data in my
stored procedure, do you know who to fix this?
Apr 09, 2012 09:52 AM|LINK
Why do you return two datasets from one stored procedure instead of having two separate stored procedures? You can only bind your GridView to one DataSet.
Apr 09, 2012 12:30 PM|LINK
because i need to bind 2 different result in 1 gridview, do you have any idea doing that? i have my sproc as below
from 1st return set, i will need to bind all result which with where cause, then for the 2nd return set i need bind all studName which already paid in the drop down list.
Now I already can display all value in the gridview, but i having problem to bind the data in the dropdownlist for user to select.
please help if you have idea on how to do that. Thanks in advance.
FROM StudentTbl St, CourseTble Ct
Where St.courseid = Ct.courseId
UserName as FullName
WHERE Paid <>
Apr 09, 2012 12:43 PM|LINK
I don't really understand...do you want to display the students that have not paid in the dropdownlist? In that case bind the DropDownList to a SqlDataSource:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT UserName as FullName FROM StudentTbl WHERE Paid <> '0'" .../>
<asp:DropDownList ID="ddl" .... DataSourceID="SqlDataSource1" DataValueField="UserName" DataTextField="UserName" />
Apr 09, 2012 12:52 PM|LINK
Sorry, i currently dont have the coding to test.. only can try again tomorrow. but the method you mention i've try this afternoon, but it seems like canot direct bind the sqlDataSource to dropdownlist in gridview, will it show error because of the gridview
already bind to other datasource?