I Am fresher to .Net, I have a doubt that, in my website i have to display the no.of people clicking on the like image for the conversation!!!!. I used repeater to display the conversation. Plzzz anyone Helpme.... Here Im attaching my code and stored procedure.
Source View:
Comments | |||
| |||
| |||
CodeView:
protected void RepDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
{
ImageButton imglike = sender as ImageButton;
Repeater RepDetail1 = (Repeater)imglike.NamingContainer;
Label lbllike = (Label)RepDetail1.FindControl("lblcount");
lblcount = lbllike.Text;
try
{
con.Open();
SqlCommand cmd = new SqlCommand("usp_likecount", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.AddWithValue("@EventID", lblID.Text);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
RepDetails.DataSource = ds;
RepDetails.DataBind();
}
Stored Procedure:
USE [*****]
GO
/****** Object: StoredProcedure [dbo].[usp_likecount] Script Date: 02/24/2014 11:38:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[usp_likecount]
(@EventID int
,@EvenConvID int)
AS
BEGIN
DECLARE @like int
SELECT @like=Likes FROM EventConv WHERE EventID=@EventID AND EvenConvID=@EvenConvID
UPDATE EventConv SET [Likes]=@like+1 WHERE EvenConvID=@EvenConvID
END

Posted Feb 23, 2014, 8:42 PM EST
Are you getting any error?
Thanks
Murali
Hima26 reputationPosted Feb 23, 2014, 10:01 PM EST
thanks&Regards.
Posted Feb 23, 2014, 11:01 PM EST
Hima26 reputationPosted Feb 23, 2014, 11:05 PM EST
[NullReferenceException: Object reference not set to an instance of an object.] Conversation.RepDetails_ItemCommand(Object source, RepeaterCommandEventArgs e) in c:\Users\crm3\Documents\Visual Studio 2010\Sports\Conversation.aspx.cs:70 System.Web.UI.WebControls.Repeater.OnItemCommand(RepeaterCommandEventArgs e) +108 System.Web.UI.WebControls.Repeater.OnBubbleEvent(Object sender, EventArgs e) +68 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.RepeaterItem.OnBubbleEvent(Object source, EventArgs e) +123 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +111 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +176 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565Posted Feb 23, 2014, 11:07 PM EST
Hima26 reputationPosted Feb 23, 2014, 11:11 PM EST
Posted Feb 23, 2014, 11:14 PM EST
Hima26 reputationPosted Feb 23, 2014, 11:16 PM EST
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Feb 23, 2014, 11:17 PM EST
Please let us know the statement which gives you error?
Hima26 reputationPosted Feb 23, 2014, 11:19 PM EST
This is the line I am getting Error
Server Error in '/Sports' Application.Object reference not set to an instance of an object.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.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 68: { Line 69: ImageButton imglike = sender as ImageButton; Line 70: Repeater RepDetail1 = (Repeater)imglike.NamingContainer; Line 71: Label lbllike = (Label)RepDetail1.FindControl("lblcount"); Line 72: lblcount = lbllike.Text;Source File: c:\Users\crm3\Documents\Visual Studio 2010\Sports\Conversation.aspx.cs Line: 70
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] Conversation.RepDetails_ItemCommand(Object source, RepeaterCommandEventArgs e) in c:\Users\crm3\Documents\Visual Studio 2010\Sports\Conversation.aspx.cs:70 System.Web.UI.WebControls.Repeater.OnItemCommand(RepeaterCommandEventArgs e) +108 System.Web.UI.WebControls.Repeater.OnBubbleEvent(Object sender, EventArgs e) +68 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.RepeaterItem.OnBubbleEvent(Object source, EventArgs e) +123 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +111 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +176 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565Version Information: Microsoft .NET Framework Version:2.0.50727.5477; ASP.NET Version:2.0.50727.5479
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Feb 23, 2014, 11:45 PM EST
Hima26 reputationPosted Feb 23, 2014, 11:50 PM EST
Thanks&Regards
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Feb 23, 2014, 11:54 PM EST
Hima26 reputationPosted Feb 23, 2014, 11:56 PM EST
But now im getting this error,
Here count is integer..
'string' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'string' could be found
Line 70: //Repeater RepDetail1 = (Repeater)imglike.NamingContainer; Line 71: Label lbllike = (Label)RepDetails.FindControl("lblcount"); Line 72: lblcount.Text = lbllike.Text; Line 73: try Line 74: {Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Feb 23, 2014, 11:59 PM EST
Hima26 reputationPosted Feb 24, 2014, 12:13 AM EST
PLz Have a look,
Posted Feb 24, 2014, 2:27 AM EST
But, you're not passing Count variable to the stored procedure. Are you using in some other places?
Hima26 reputationPosted Feb 24, 2014, 2:37 AM EST
Posted Feb 24, 2014, 2:40 AM EST
count = Convert.ToInt32( lbllike.Text);
Hima26 reputationPosted Feb 24, 2014, 3:21 AM EST
Sai Prasad Anumolu175 reputationPosted Mar 2, 2014, 9:19 PM EST