code
if (!IsPostBack)
{
string strr = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
string getPOST = "GetMessage";
using (SqlConnection conn = new SqlConnection(strr))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(getADPOST, conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", username);
// cmd.Parameters.AddWithValue("@Name", username);
// cmd.Parameters.AddWithValue("@FriendUserName", username);
// cmd.Parameters.AddWithValue("@FollowingId", follower);
//
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[1] { new DataColumn("Name") });
dt.Columns.AddRange(new DataColumn[2] { new DataColumn("UserName"), new DataColumn("FriendUserName") });
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("ContentPost"), new DataColumn("ImageName1") });
dt.Columns.AddRange(new DataColumn[4] { new DataColumn("ImageNam2"), new DataColumn("ImageName3") });
dt.Columns.AddRange(new DataColumn[5] { new DataColumn("ImageName4") });
SharePost.DataSource = dt;
SharePost.DataBind();
i got this error after running the code
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: CS0847: An array initializer of length '3' is expected
Source Error:
Line 84: dt.Columns.AddRange(new DataColumn[1] { new DataColumn("Name") });
Line 85: dt.Columns.AddRange(new DataColumn[2] { new DataColumn("UserName"), new DataColumn("FriendUserName") });
Line 86: dt.Columns.AddRange(new DataColumn[3] { new DataColumn("ContentPost") });
Line 87: dt.Columns.AddRange(new DataColumn[4] { new DataColumn("ImageNam2"), new DataColumn("ImageName3") });
Line 88: dt.Columns.AddRange(new DataColumn[5] { new DataColumn("ImageName4") });
JAVASCRIPT
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript">
$("[id*=ShowSelectedRecord]").live("click", function () {
$("#Name").html($("[id*=lblName]", $(this).closest("tr")).html());
$("#UserName").html($("[id*=lblUserName]", $(this).closest("tr")).html());
$("#FriendUserName").html($("[id*=lblFriendUserName]", $(this).closest("tr")).html());
$("#ContentPost").html($("[id*=lblContentPost]", $(this).closest("tr")).html());
$("#ImageNam2").html($("[id*=lblgetSRC]", $(this).closest("tr")).html());
$("#SendDate").html($("[id*=lblSendDate]", $(this).closest("tr")).html());
$("#dialog").dialog({
title: "Selected Row",
buttons: {
Ok: function () {
$(this).dialog('close');
}
}
});
return false;
});
</script>