am trying to display data on model by clicking the id on a datalist display, but i got these errors
datalist
<asp:UpdatePanel ID="updResult" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DataList ID="GetMergedAll" runat="server" DataKeyName="Id" OnRowCommand="GetMergedAll_RowCommand"
OnItemCommand="GetMergedAll_ItemCommand">
<ItemTemplate>
<asp:Label ID="name " runat="server"></asp:Label>
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</asp:UpdatePanel>
model display markup
<asp:UpdateProgress ID="UpdateProgressmodelshare" runat="server">
<ProgressTemplate>
<img src="" alt="Loading... Please wait !" />
</ProgressTemplate>
</asp:UpdateProgress>
<!-- Modal share category -->
<div class="modal fade" id="myModal9t" role="dialog" data-backdrop="static">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header" style="background-color: #31b0d5">
<button type="buttonclose" class="close" data-dismiss="modal">
×</button>
<h4 class="modal-title" style="color: white">
Share This</h4>
</div>
<div class="modal-body">
<div class="col-sm-12">
<div id="" class="">
</div>
<asp:UpdatePanel ID="UpdatePanel2model" runat="server">
<ContentTemplate>
<br />
<asp:FormView ID="SharePost" runat="server" CssClass=" table table-bordered table-striped table-hover">
<ItemTemplate>
<asp:Label ID="name " runat="server"></asp:Label>
</ItemTemplate>
</asp:FormView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GetMergedAll" EventName="RowCommand" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
<div class="clearfix">
</div>
<div class="modal-footer">
<button type="button" class=" btn btn-default" data-dismiss="modal" style="">
Close</button>
<asp:LinkButton ID="LinkButton6" runat="server" CssClass="btn btn-twitter" Font-Bold="True"><i class="fa fa-share" style="font-weight: bold; margin-right:3px; font-size: large;"></i></asp:LinkButton>
</div>
</div>
</div>
</div>
code
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (this.Page.User.Identity.IsAuthenticated)
{
string username = this.Page.User.Identity.Name;
GetProfile(username);
}
}
}
public void GetProfile(string username)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
SqlDataAdapter adp = new SqlDataAdapter("GetUserPOSTS", con);
adp.SelectCommand.CommandType = CommandType.StoredProcedure;
adp.SelectCommand.Parameters.AddWithValue("@Name", username);
adp.SelectCommand.Parameters.AddWithValue("@UserName", username);
// adp.SelectCommand.Parameters.AddWithValue("@Eamil", username);
DataTable dt = new DataTable();
// dt.Columns.AddRange(new DataColumn[5]);
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
GetMergedAll.DataSource = dt;
GetMergedAll.DataBind();
}
}
protected void GetMergedAll_RowCommand(object sender, DataListCommandEventArgs e)
{
if (e.CommandName.Equals("Share"))
{
int index = Convert.ToInt32(e.CommandArgument);
// string id = GetMergedAll.DataKeys[index].Value.ToString();
IEnumerable<DataRow> query = from i in dt.AsEnumerable()
// where i.Field<String>(Id).Equals(id)
select i;
DataTable detailTable = query.CopyToTable<DataRow>();
SharePost.DataSource = detailTable;
SharePost.DataBind();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(@"<script type='text/javascript'>");
sb.Append("$('#myModal9t').model('show');");
sb.Append(@"</script>");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
"ModelScript", sb.ToString(), false);
}
}
here are the errors
ERROR
Server Error in '/' Application.
Could not find an event named 'RowCommand' on associated control 'GetMergedAll' for the trigger in UpdatePanel 'UpdatePanel2model'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Could not find an event named 'RowCommand' on associated control 'GetMergedAll' for the trigger in UpdatePanel 'UpdatePanel2model'.
Source Error:
//////
ERROR 2
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'object' does not contain a definition for 'Value' and no extension method 'Value' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 65:
Line 66: int index = Convert.ToInt32(e.CommandArgument);
Line 67: string id = GetMergedAll.DataKeys[index].Value.ToString();
Line 68: // IEnumerable<DataRow> query = from i in dt.AsEnumerable()
Line 69: // where i.Field<String>(Id).Equals(id)
ERROR 3
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Id' does not exist in the current context
Source Error:
Line 67: // string id = GetMergedAll.DataKeys[index].Value.ToString();
Line 68: IEnumerable<DataRow> query = from i in dt.AsEnumerable()
Line 69: where i.Field<String>(Id).Equals(id)
Line 70: select i;
Line 71:
// DataTable detailTable = query.CopyToTable<DataRow>();
ERROR 4
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'System.Collections.Generic.IEnumerable<System.Data.DataRow>' does not contain a definition for 'CopyToTable' and no extension method 'CopyToTable' accepting a first argument of type 'System.Collections.Generic.IEnumerable<System.Data.DataRow>' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 69: // where i.Field<String>(Id).Equals(id)
Line 70: select i;
Line 71: DataTable detailTable = query.CopyToTable<DataRow>();
Line 72: SharePost.DataSource = detailTable;
Line 73: SharePost.DataBind();