c# - DropDownList.DataTextField can't be bound to a dataset? -
i'm trying bind dataset
dropdownlist
, throws httpexception
here's i'm trying do
if (dsgroupsnotonfestival.tables[0].rows.count > 0) { //bind dataset new group selection ddlnewgroup.datasource = dsgroupsnotonfestival.tables[0].defaultview; ddlnewgroup.datavaluefield = "band_id"; ddlnewgroup.datatextfield = "band_naam"; ddlnewgroup.databind(); } else { ddlnewgroup.items.add(new listitem("no groups add")); }
the exception message:
databinding: 'system.data.datarowview' not contain property name 'band_naam'.
i'm absolutely positive dataset
contains column title band_naam. can see, exception thrown when binding datatextfield
, meaning datavaluefield
bound correctly, right?
edit:
this stored procedure:
use [groep2_festivals] go /****** object: storedprocedure [dbo].[getgroupsoffestival] script date: 14-05-13 12:31:18 pm ******/ set ansi_nulls on go set quoted_identifier on go -- ============================================= -- author: robbie vercammen -- create date: 2013-05-09 -- description: getting groups defined festival -- ============================================= alter procedure [dbo].[getgroupsoffestival] ( @festid nvarchar(4) ) begin declare @query varchar(255) select b.*, p.* bands b join bandsperfestival bpf on b.band_id = bpf.band_id join podia p on p.pod_id = bpf.pod_id fest_id @festid exec(@query) end
notice b.*
, bands b
? here table:
this stored procedure has been used on multiple occasions, i'm pretty sure works correctly. here's perhaps important code forgot mention:
//filling dataset groups not on festival dsgroupsnotonfestival.tables.add(new datatable()); foreach (datarow row in dsgroupsall.tables[0].rows) { if (!dsgroupsperfestival.tables[0].rows.equals(row)) { dsgroupsnotonfestival.tables[0].importrow(row); } }
and once again, dataset
dsgroupsall has been used before data present :)
@manish mishra dsgroupsall filled same stored procedure above. prove there data in there:
for still following, i've confirmed there 14 rows in dsgroupsnotonfestival
. when i'm trying value in simple way, example:
string strresult = dsgroupsnotonfestival.tables[0].rows[0][0].tostring();
i exception saying column 0 not found... why that?
i'm absolutely positive dataset contains column title band_naam.
i understand how feel, i'm absolutely positive there isn't one because error extremely explicit:
does not contain property name 'band_naam'
have @ code fills dataset
. defaultview
perfect image of datatable
, of course result set of query, query you're using fill datatable
missing field.
maybe it's calculated field , forgot as
keyword give column name.
edit
based on feedback (i.e. screenshots of queries , schema), i'm going habib hit right on head in comments, change line:
ddlnewgroup.datasource = dsgroupsnotonfestival.tables[0].defaultview;
to line:
ddlnewgroup.datasource = dsgroupsnotonfestival.tables[0];
i have never had problem binding defaultview
don't feel there other possibilities left.
Comments
Post a Comment