How do i use Datalist selextedIndex to select record from datalist and display the record in Formview in modal My preious code
static string username = string.Empty;
static int Id = 0;
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();
if (dt.Rows.Count > 0)
{
GetMergedAll.DataSource = dt;
GetMergedAll.DataBind();
}
}
}
}
public DataTable GetProfile()
{
SqlConnection constr = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
SqlDataAdapter adp = new SqlDataAdapter("GetUserPOSTS", constr);
adp.SelectCommand.CommandType = CommandType.StoredProcedure;
// adp.SelectCommand.Parameters.AddWithValue("@Email", username);
adp.SelectCommand.Parameters.AddWithValue("@UserName", username);
adp.SelectCommand.Parameters.AddWithValue("@Id", Id);
DataTable dt = new DataTable();
adp.Fill(dt);
return dt;
}
protected void GetMergedAll_SelectedIndexChanged(object sender, EventArgs e)
{
}