Migold Live

Migold Live

  • NA
  • 34
  • 1.9k

selecting data from datalist and display on modal

Nov 4 2016 1:30 PM
Hi am having issues with selecting data on datalist and display it on formview in modal popup, but the data is not displaying on modal after click .
 
 
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (this.Page.User.Identity.IsAuthenticated)
{
username = this.Page.User.Identity.Name;
DataTable dt = GetProfile();
GetMergedAll.DataSource = dt;
ViewState["DataTable"] = dt;
GetMergedAll.DataBind();
}
}}
public DataTable GetProfile()
{
string constr = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
// using (SqlCommand cmd = new SqlCommand("select * from GetUserPOSTS"))
{
SqlDataAdapter sda = new SqlDataAdapter("GetUserPOSTS", constr);
{
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
// adp.SelectCommand.Parameters.AddWithValue("@Email", username);
sda.SelectCommand.Parameters.AddWithValue("@UserName", username);
sda.SelectCommand.Parameters.AddWithValue("@Id", Id);
// cmd.Connection = con;
// sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
return dt;
}
}
}
}
}
protected void GetMergedAll_ItemCommand1(object source, DataListCommandEventArgs e)
{
if (e.CommandName== "SharePost")
{
- int index = Convert.ToInt32(e.CommandArgument);
DataTable dt = (DataTable)ViewState["DataTable"];
IEnumerable query = from i in dt.AsEnumerable()
where i.Field("Id").Equals(index)
select i;
DataTable detailTable = query.CopyToDataTable();
SharePost.DataSource = detailTable;
SharePost.DataBind();
}
}
protected void btnClick_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
}
 

Answers (1)