using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
public partial class Default2 : System.Web.UI.Page
{
string strSql = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GetBinder(16);
}
}
private void GetBinder(int researchId)
{
string url = "server=192.168.1.125;database=Skandia;uid=sa;pwd=sa";
SqlConnection con = new SqlConnection(url);
string sql = "select * from researchQuestions where researchId=" + researchId;
//SqlDataAdapter adapter = new SqlDataAdapter(sql, con);
//DataSet ds = new DataSet();
//adapter.Fill(ds);
SqlCommand cmd = new SqlCommand(sql, con);
try
{
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
this.dlMyList.DataKeyField = "questionId";
this.dlMyList.DataSource = sdr;
this.dlMyList.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
}
//DataSet ds1 = new DataSet();
//for(int i=0;i<dlMyList.Items.Count;i++)
//{
// string sql1 = "select * from researchOptions where questionId="+ds.Tables[0].Rows[i]["questionId"].ToString();
// SqlDataAdapter ada = new SqlDataAdapter(sql1, con);
// ada.Fill(ds1);
// DataList myList = (DataList)dlMyList.Items[i].FindControl("MyList");
// myList.DataSource = ds1.Tables[0];
// myList.DataBind();
//}
}
protected void dlMyList_ItemDataBound(object sender, DataListItemEventArgs e)
{
string url = "server=192.168.1.125;database=Skandia;uid=sa;pwd=sa";
SqlConnection con = new SqlConnection(url);
DataSet ds = new DataSet();
string sql = "select * from researchOptions where questionId =" + dlMyList.DataKeys[e.Item.ItemIndex].ToString();
SqlCommand cmd = new SqlCommand(sql, con);