Click here to Skip to main content
15,914,452 members
Home / Discussions / C#
   

C#

 
GeneralRe: NBIS biometric image software Pin
Rajesh Anuhya23-Mar-09 1:55
professionalRajesh Anuhya23-Mar-09 1:55 
QuestionSerialize an Object with XmlSerializer Pin
Ido22-Mar-09 22:25
Ido22-Mar-09 22:25 
AnswerRe: Serialize an Object with XmlSerializer Pin
Spunky Coder22-Mar-09 22:43
Spunky Coder22-Mar-09 22:43 
GeneralRe: Serialize an Object with XmlSerializer Pin
Ido22-Mar-09 22:52
Ido22-Mar-09 22:52 
GeneralRe: Serialize an Object with XmlSerializer Pin
Spunky Coder22-Mar-09 23:07
Spunky Coder22-Mar-09 23:07 
QuestionHelp needed in finding control Pin
The Pod22-Mar-09 21:51
The Pod22-Mar-09 21:51 
AnswerRe: Help needed in finding control Pin
Mycroft Holmes22-Mar-09 22:38
professionalMycroft Holmes22-Mar-09 22:38 
QuestionGridview, databind retrieving value from database Pin
Julius8822-Mar-09 21:40
Julius8822-Mar-09 21:40 
Hey people. I am currently doing a social portal like Facebook. What i am facing over now is whenever a user makes an update, for example : Posted a new status or note.

Below, when pple click on the Note button, it will display the top 5 updates from the database. But this raises a question. Every update will have an UpdateID, but how do i actually know what updateID are they each.
This is because i allow other users to comment on each of these update. Without capturing the UpdateID, i will have trouble in inserting the right Comments onto the status or note.
Hope you guys understand what i am trying to intepret over here.



Source code

asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderStyle="None" Height="0px" Width="443px" GridLines="None" OnRowCommand="GridView1_RowCommand">

<Columns>

<asp:TemplateField>

<EditItemTemplate>

<asp:TextBox ID="CommentText" runat="server" Text='<%# Bind("FullName") %>'></asp:TextBox>

</EditItemTemplate>

<ItemTemplate>

<a href = ""><asp:Label ID="Label1" runat="server" Text='<%# Bind("FullName") %>'></asp:Label></a> wrote a note.<br /><br />

<asp:Label ID="Label2" runat="server" Text='<%# Bind("TextInput") %>'></asp:Label><br /><br />

<asp:Button ID="WriteComment" runat="server" Text="Write Comment" Visible ="true"/><br /><br />

<asp:TextBox ID="Notestxtbox" runat="server" Columns="36" TextMode="MultiLine" MaxLength="100" Height="60px" Width="304px" Visible ="False"></asp:TextBox>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<asp:Button ID="ViewComment" runat="server" OnClientClick="window.open('ViewComment.aspx','','left=100,top=50,width=500,height=500,scrollbars=1');return false;" PostBackUrl="~/ViewComment.aspx" Text="View Comment" Visible ="false"/>

<asp:Button ID="NotePost" runat="server" OnClick="NotePost_Click" Text="Post" Visible ="false"/>&nbsp;<br /><br />

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>





Cs code

protected void NotePost_Click(object sender, EventArgs e)
{

foreach (GridViewRow row in GridView1.Rows)
{
// Selects the text from the TextBox
// which is inside the GridView control

string textBoxText = ((TextBox)row.FindControl("Notestxtbox")).Text;
TextBox noteText = ((TextBox)row.FindControl("Notestxtbox"));

if (textBoxText != "")
{
string strConnectionString = ConfigurationManager.ConnectionStrings["SocialSystemConnectionString"].ConnectionString;
SqlConnection myConnect = new SqlConnection(strConnectionString);

SqlCommand cmd = new SqlCommand("INSERT INTO [Comment] (TypeId,Email,TextInput,UpdateID) VALUES (@TypeId,@Email,@TextInput,@UpdateID)", myConnect);
cmd.Parameters.Add("@TypeId", SqlDbType.VarChar);
cmd.Parameters["@TypeId"].Value = "Notes";
cmd.Parameters.Add("@Email", SqlDbType.VarChar);
cmd.Parameters["@Email"].Value = Emaillbl.Text; //Session
cmd.Parameters.Add("@TextInput", SqlDbType.VarChar);
cmd.Parameters["@TextInput"].Value = textBoxText;
cmd.Parameters.Add("@UpdateID", SqlDbType.VarChar);
cmd.Parameters["@UpdateID"].Value = UpdateIDlbl.Text; //Session

myConnect.Open();
cmd.ExecuteNonQuery();
myConnect.Close();

noteText.Text = "";
}
}

}

protected void Notebtn_Click(object sender, EventArgs e)

{

GridView1.Visible = true;

GridView2.Visible = false;

GridView3.Visible = false;

string strConString = ConfigurationManager.ConnectionStrings["SocialSystemConnectionString"].ConnectionString;

SqlConnection con = new SqlConnection(strConString);

SqlCommand cmd = new SqlCommand("SELECT TOP 5 Types.TypeID, [Update].TextInput, [Update].UpdateID, [User].FullName FROM Types INNER JOIN [Update] ON Types.TypeID = [Update].TypeId INNER JOIN [User] ON [Update].Email = [User].Email WHERE [Update].TypeId = 'Notes' ORDER BY [Update].UpdateTime DESC", con);

con.Open();

SqlDataReader reader = cmd.ExecuteReader();

GridView1.DataSource = reader;

GridView1.DataBind();

reader.Close();

con.Close();

}

Learning

AnswerRe: Gridview, databind retrieving value from database Pin
Mycroft Holmes22-Mar-09 22:43
professionalMycroft Holmes22-Mar-09 22:43 
GeneralRe: Gridview, databind retrieving value from database Pin
Julius8822-Mar-09 23:13
Julius8822-Mar-09 23:13 
Questiona href issue Pin
Julius8822-Mar-09 20:56
Julius8822-Mar-09 20:56 
AnswerRe: a href issue Pin
Ravi Mori22-Mar-09 21:16
Ravi Mori22-Mar-09 21:16 
AnswerRe: a href issue Pin
Christian Graus22-Mar-09 21:38
protectorChristian Graus22-Mar-09 21:38 
GeneralRe: a href issue Pin
Julius8822-Mar-09 23:15
Julius8822-Mar-09 23:15 
GeneralRe: a href issue Pin
benjymous22-Mar-09 23:35
benjymous22-Mar-09 23:35 
GeneralRe: a href issue Pin
Dave Kreskowiak23-Mar-09 3:50
mveDave Kreskowiak23-Mar-09 3:50 
QuestionHow to get the value of the existing cookie. Pin
Nekkantidivya22-Mar-09 19:42
Nekkantidivya22-Mar-09 19:42 
AnswerRe: How to get the value of the existing cookie. Pin
N a v a n e e t h22-Mar-09 20:01
N a v a n e e t h22-Mar-09 20:01 
Questionhelp on GUI foe Deploy Pin
varun.g22-Mar-09 19:29
varun.g22-Mar-09 19:29 
AnswerRe: help on GUI foe Deploy Pin
N a v a n e e t h22-Mar-09 19:40
N a v a n e e t h22-Mar-09 19:40 
Questionmenu in asp.net Pin
Mangesh Tomar22-Mar-09 19:03
Mangesh Tomar22-Mar-09 19:03 
AnswerRe: menu in asp.net Pin
Christian Graus22-Mar-09 20:39
protectorChristian Graus22-Mar-09 20:39 
Questionrun time exception Pin
Mangesh Tomar22-Mar-09 18:31
Mangesh Tomar22-Mar-09 18:31 
AnswerRe: run time exception Pin
Cracked-Down22-Mar-09 18:50
Cracked-Down22-Mar-09 18:50 
GeneralRe: run time exception Pin
Mangesh Tomar22-Mar-09 19:01
Mangesh Tomar22-Mar-09 19:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.