TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Fares Ayyad
NA
235
74.6k
C#:Change repeater data based on dropdownlist
Oct 24 2016 2:28 AM
Hello
I'm working on project that have a repeater and a dropdownlist.
DropDownList with AutoPostBack:
<asp:DropDownList ID=
"ddlTer"
runat=
"server"
AutoPostBack=
"true"
></asp:DropDownList>
This is the repeater in .aspx page:
asp:Repeater ID=
"rptDep"
runat=
"server"
>
<HeaderTemplate>
<table
class
=
"table table-hover table-striped table-condensed table-bordered table-responsive"
>
<tr>
<th>Deposit No.</th>
<th>Territory</th>
<th>Deposit Date</th>
<th>Custom Declaration No.</th>
<th>Goods Description</th>
<th>Units Balance</th>
<th>WT Balance</th>
<th>Goods Balance Amount(LC)</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td> <%#Eval(
"cdin_Serial"
) %></td>
<td><%#Eval(
"terr"
) %></td>
<td><%#Eval(
"customDec"
) %></td>
<td><%#Eval(
"cdin_startunstufdate"
) %></td>
<td><%#Eval(
"cdin_goodsDesc"
) %></td>
<td><%#Eval(
"unitsBal"
) %></td>
<td><%#Eval(
"wtBal"
) %></td>
<td><%#Eval(
"currBal"
) %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
How i populate Data in DropDownList:
var ids =
new
List<
int
> { -1342177274, -1073741819, -805306364, -536870909, -268435454, 1, 268435456 };
var tc = (from t
in
db.Territories
where ids.Contains(t.Terr_TerritoryID)
select
new
{
terCapt = t.Terr_Caption,
terID = t.Terr_TerritoryID
}
);
ddlTer.DataSource = tc.ToList();
ddlTer.DataValueField =
"terID"
;
ddlTer.DataTextField =
"terCapt"
;
ddlTer.SelectedValue =
"-1073741819"
;
ddlTer.DataBind();
Integer declaration to know the select value.
int
selected =
int
.Parse(ddlTer.SelectedValue);
Query to select data from database, and passing the Selected value
var query = (from cdin
in
db.CDIndexes
join comp
in
db.Companies on cdin.cdin_CompanyId equals comp.Comp_CompanyId
join terr
in
db.Territories on cdin.cdin_Secterr equals terr.Terr_TerritoryID
join gds
in
db.Goods on cdin.cdin_CDIndexID equals gds.good_GoodsID
where cdin.cdin_Status ==
"InProgress"
&&
cdin.cdin_CompanyId == 83 &&
cdin.cdin_Secterr == selected &&
cdin.cdin_CDIndexID == 4 &&
cdin.cdin_Deleted ==
null
&&
comp.Comp_Deleted ==
null
//&& cdin.cdin_Secterr= -1073741819 && cdin.cdin_CompanyId=83 cdin.cdin_Deleted = null && comp.Comp_Deleted = null &&
select
new
{
cdin_Serial = cdin.cdin_Serial,
cdin_startunstufdate = cdin.cdin_startunstufdate,
cdin_goodsDesc = cdin.cdin_goodsDesc,
terr = terr.Terr_Caption,
customDec = cdin.cdin_Customdeclar,
unitsBal = cdin.cdin_RemainPackages,
wtBal = cdin.cdin_RemainWT,
currBal = cdin.cdin_ActMortgageAmnt,
gdsDesc = gds.good_Name,
gdUnitBal = gds.good_RemainPackages,
gdWtBal = gds.good_RemainWT,
}
.ToList();
Binding the repeater:
rptDep.DataSource = query;
rptDep.DataBind();
Note that : all the code above is warped by if(!isPostBack)
what i want is how to change the data in repater if the dropdown list selected item changed.
Reply
Answers (
3
)
Retrieve data into repeater using ajax in asp.net
How to open a camera using asp.net