Last post Apr 10, 2012 01:47 AM by aoshi_kh
Apr 09, 2012 03:52 AM|aoshi_kh|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 05:00 AM|mm10|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 05:03 AM|gaikwad_anil1987|LINK
cehck below link
Apr 09, 2012 05:09 AM|aoshi_kh|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 05:37 AM|mm10|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 05:41 AM|aoshi_kh|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 05:52 AM|mm10|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 08:30 AM|aoshi_kh|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 08:43 AM|mm10|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 08:52 AM|aoshi_kh|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?
Apr 09, 2012 08:59 AM|mm10|LINK
If you place your DropDownList inside a TemplateField you can certainly bind it to a SqlDataSource:
<asp:TemplateField HeaderText="Dropdownlist column">
<asp:DropDownList ID=".." DataSourceID="".... />
Apr 09, 2012 07:58 PM|aoshi_kh|LINK
getting message show that 'the active schema does not support the element 'asp:sqldatasource', do you know how to resolve this issue?
Apr 09, 2012 08:01 PM|aoshi_kh|LINK
and also getting message show 'Could not find any attribute 'datasourceId' of element 'dropdownlist'
Apr 09, 2012 08:46 PM|aoshi_kh|LINK
is this related to i using asp:datagrid? if so, do you know how to set if i using asp:datagrid??
Apr 10, 2012 01:47 AM|aoshi_kh|LINK
I have solve all issue, by declare the another datasource in coding page, then bind in the datagrid when edit button is click.