|
Hi guys, i have encountered a problem in finding control.
i have binded data to a label in a datalist to retreive a email and it works. but next, i have a new label by the name of "Testing". How do i grab the bound data from the label to put into a string?
Below will be the code i have on hand:
Part of the source code will be like
<asp:label id="Testing" text="<#% Eval(" email")%>"="" xmlns:asp="#unknown">
How do i grab the eval email value and put to a string? Kindly please help, thanks guys
|
|
|
|
|
looks like ASP to me - go there.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
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>
<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"/> <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
|
|
|
|
|
Julius88 wrote: Without capturing the UpdateID
You need to get this otherwise how do you expect to find the record to update.
There are number of things wrong here
1 you are asking an ASP ? in the C# forum
2 You have dumped in a large amount of useless code
3 Your code is open to SQL injection - always a bad idea.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Erm. I am using C# for this particular project. Isn't it?
Sorry if i misintepret.
Learning
|
|
|
|
|
Hi People. I am currently facing a problem to allow a href on a Databind item. For example, The TextInput stated below will retrieve all the links posted by a user. For instance, if a user posted www.youtube.com or www.friendster.com, it will allow them to click on the Label and proceed to the link in a new window. Could someone advise me how to work on it?
Code
<a href = ""> <asp:Label ID="Label2" runat="server" Text='<%# Bind("TextInput") %>'></asp:Label></a><br /><br />
Learning
|
|
|
|
|
|
What is it with people too dumb to ask in the ASP.NET forum ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Erm. I am using C# for this particular project. Isn't it?
Sorry if i misintepret.
And just to remind you, you're kinda rude over here. Although you have contributed to this forum alot, it doesn't mean you can use the word dumb .
Learning
|
|
|
|
|
The issue is that your problem is more "web coding" related than it is "c#" related.
I don't do any ASP coding in C#, just WinForms, so I'll ignore such questions. People who know about web stuff are likely to read the ASP forum, and thus are far more likely to give you a useful answer
|
|
|
|
|
Well, considering your question had nothing to do with C#, but everything to do with ASP.NET, wouldn't it have been better to post in a more appropriate forum??
|
|
|
|
|
Hi,
How to get the values in a existing cookie into a windows application.Please reply me if you know solution.
Note: Request.cookie is not working in windows application
Thank you
|
|
|
|
|
You need to find out the location where cookies are stored(depends on each browser). Now read it as a normal file.
|
|
|
|
|
Hi Fellows
now let me ask you another doubt,I hope i'll get solved it quick.
1.i am working(programming)with visual studio 2005.
2.how to change the deployment aspects according to my likeness.
3.In Detail: How to change the place of bitmap and buttons in installation windows.
4.how to change progressbar style/color in installation windows.
Please give me any link that desribs abt Visual studiol deployment specifying the graphical modules
|
|
|
|
|
Your post has nothing to do with C#. Try Visual Studio[^] discussion board.
|
|
|
|
|
How i cam hide menu dynamically
|
|
|
|
|
You didn't notice that we have an ASP.NET forum ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
HI
here is my code i take 1 txt,1datagride,2 button,1 file dialog box .
on 1 button i open filedialog box select 1 excel file and fetch string in to txt box,and try to open this excel file in datagride view
WHEN I RUN MY PROGRAM A RUN TIME EXCEPTION THROWEN BY OLEDB IE,
Cannot update. Database or object is read-only.
error occures at connection.Open();
my excel file close when program running.
PLZ HELP
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;
namespace filedialog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
private void button2_Click(object sender, EventArgs e)
{
string filename = @"textBox1.Text";
String connectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + filename + ";" +
"Extended Properties=Excel 8.0;";
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
//String connectionString="Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source="+filename +";"+"Extended Properties=Excel 8.0;";
OleDbCommand selectCommand = new OleDbCommand("SELECT * FROM [sheet1$]", connection);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
dataAdapter.SelectCommand = selectCommand;
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
// double sum = 0.0;
// We'll make some assumptions for brevity of the code.
System.Data.DataTable dataTable = dataSet.Tables[0];
dataGridView1.DataSource = dataSet.Tables[0];
MessageBox.Show(dataGridView1.RowCount.ToString());
connection.Close();
//openFileDialog1.ShowDialog();
//openFileDialog1.ShowDialog();
// return sum;
// directorySearcher1.FindAll();
}
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog FD = new OpenFileDialog();
FD .Filter="Excel|*.xls";
if (FD.ShowDialog() == DialogResult.OK)
{
textBox1.Text = " " + FD.FileName;
}
}
}
}
|
|
|
|
|
Are you trying to open the file that you are providing from Text Box??
if you are doing so then,
string filename = @"textBox1.Text";
this statement is wrong you should not precede with @ here,which means take the followed string as it is! In your case filename is takes as "textBox1.Text" which is not the file which you want to access.......
so change your line by removing @ symbol and qoutes.....
so your this line should be like this
string filename = textBox1.Text;
which will give you the file name provided in the testbox
hope this will work for you............
Happy coding!!!!!!
Deep
|
|
|
|
|
|
Hi,
The MMC SnapIn I'm developing has configuration data that has to be committed by the user.
So if the user has made some changes, but not yet committed the changes, how can you catch the fact that the MMC console is trying to exit, and allow the user the option to stop it exiting so they can commit the changes?
The SnapInBase class has an OnShutdown override method, but in the docs for this, it says that you must not bring up a modal dialog while it is being called. It's also not clear how to abort the exit from within this call.
Any help would be appreciated.
Peter
|
|
|
|
|
Hi all
I want to change ipdaddress on pda, which connected activesync
ip address "192.168.55.101" gateway "192.168.55.100"
I use IOCTL_NDIS_GET_ADAPTER_NAMES and IOCTL_NDIS_GET_ADAPTER_BINDINGS
but that name is "PPTP"
how to change ipaddress at activesync ?
|
|
|
|
|
Hi
I am building a windows Form application where the Forms names are stored in a data table as text , The name of the Form selected to run is retrieved from the data table , so it will be a string type , how can I call the related form knowing its name as a string only ?
Any Ideas ?
|
|
|
|
|
Via Reflection. Search the articles here for "plug-ins" and "add-ons" and "dynamic loading" and such.
|
|
|
|
|
use reflection,you can find the guideline about using this from msdn or google,it's quite easy..
|
|
|
|