我有一个下拉 Web 服务器控件,它与数据库中的数据源绑定..当我选择一个值时,它总是返回按钮单击列表中第一项的值,请解决此问题..这是使用的代码
using JobPortel.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace JobPortel
{
public partial class receivedresume : System.Web.UI.Page
{
MemberDTO memberobj;
int orgid;
Utilities util;
String jobidString;
List<JobDto> joblist;
protected void Page_Load(object sender, EventArgs e)
{
String UserName = (String)Session["UserName"];
util = new Utilities();
memberobj = util.getMember(UserName);
orgid = util.getOrganizationIdFromMember(memberobj.ID);
joblist = util.getJobList(orgid);
this.joblistdropdown.DataSource = joblist;
joblistdropdown.DataTextField = "Jobtitle";
joblistdropdown.DataValueField = "Id";
this.joblistdropdown.DataBind();
}
if (IsPostBack) {
jobidString = this.joblistdropdown.SelectedValue;
}
}
protected void savebtn_Click(object sender, EventArgs e)
{
int jobid = 0;
jobid = Convert.ToInt32(jobidString);
List<MemberDTO> cvlist = new List<MemberDTO>();
using (var db = new jobportaldatabaseEntities1()) {
var query = from m in db.Members
join p in db.applyjobtables on m.Id equals p.applicantid
where p.jobid == jobid
select m;
foreach (var item in query)
{
MemberDTO member = new MemberDTO();
member.ID = item.Id;
member.FirstName = item.firstname;
member.Lastname = item.lastname;
member.Location = item.location;
member.Mobile = item.mobile;
member.Email = item.email;
cvlist.Add(member);
}
}
this.cvgridview.DataSource = cvlist;
this.cvgridview.DataBind();
}
}
}