|
Override the ItemDataBound event and insert whatever controls you want.
only two letters away from being an asset
|
|
|
|
|
i m using c#.net not c#asp.net.can u plz tell me then what to do?
|
|
|
|
|
You are confused. C# is a langauge that implements .NET Framework. ASP.NET is a platform for developing and delivering web applications. DataGrid is a control used in Web Forms and GridView is a control used in Win Forms.
If you would explain clearly, with correct terminology, your chances of recieving an answer would be enhanced.
only two letters away from being an asset
|
|
|
|
|
sorry.i was making mistake.i want to implement this using dataGridView.now can u plz tell me?
i want to add table in a column just like this bold statement.but this is for datagrid can u tel me for gridview.
public void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
e.Item.Cells.RemoveAt(2);
e.Item.Cells[1].ColumnSpan = 2;
e.Item.Cells[1].Text = "<table style='FONT-WEIGHT: bold;WIDTH: 100%; COLOR: Black; TEXT-ALIGN: center'><tr align=center><td colspan = 2 style='BORDER-BOTTOM:cccccc 1pt solid'>Name</td></tr><tr align =center ><td style ='BORDER-RIGHT: cccccc 1pt solid'>FName</td>< td>LName</td></tr></table>";
}
}
modified on Monday, January 26, 2009 4:23 AM
|
|
|
|
|
G'day all,
I'm writing an application that requires me to output the values stored within a DataGridView to an cls/csv file (or basically anything that M$ Excel can read). This is as far as i have gotten:
string strValue = " ";
for (int i = 0; i < stocksDataGridView.Rows.Count - 1; i++)
{
for (int j = 0; j < stocksDataGridView.Rows[i].Cells.Count; j++)
{
if (!string.IsNullOrEmpty(stocksDataGridView[j, i].Value.ToString()))
{
if (j > 0)
strValue += "," + stocksDataGridView[j, i].Value.ToString();
else
{
if (!String.IsNullOrEmpty(strValue))
strValue = stocksDataGridView[j, i].Value.ToString();
else
strValue = strValue + Environment.NewLine + stocksDataGridView[j, i].Value.ToString();
}
}
}
strValue = strValue + Environment.NewLine;
}
string fileName = @saveFileDialog1.FileName;
if (File.Exists(fileName) && !String.IsNullOrEmpty(strValue))
{
File.WriteAllText(fileName, strValue);
}
I'm sure its not very pretty and i have no idea how/where/why i have it in there, but all i can say is that it doesn't actually output anything.
Any and all help will be greatly appreciated.
Thanks in Advance,
Tom
|
|
|
|
|
Hi Tom,
are you sure that the command "File.WriteAllText" is executed? You only enter the if-block if your file exists! Maybe you have forgotten a "!" before "File.Exists"?
Regards
Sebastian
|
|
|
|
|
Thankyou so very much. I can't believe I would screw up something like that! Man I must be getting old...
Thankyou again,
Tom
|
|
|
|
|
Hello, Please help how to save Listview data to MSSQL database?
|
|
|
|
|
Tuntgerhuu wrote: how to save Listview data to MSSQL database
By iterating the listview rows. For connecting MySQL use the connector[^] provided by MySQL.
|
|
|
|
|
he want to use MSSQL, not MySQL,
Glad to discuss with you and best wishes.
|
|
|
|
|
oops. I read it as MySQL. My bad
|
|
|
|
|
|
Hi there i am a little stuck and need some assistance
The gist is i am calling a stored procedure from my executable, it takes to parameters FileName and FileType and returns an error/success code.
Based upon that error code i need to do some work.
In esscence this is the form i want
EXEC @Return_Code = the_StoredProcedureToCall ‘C:\\File.csv’, ‘FileType’
where @Return_Code = return status code
Within my C# i have the following.
private int callStoredProc(string fullPath, string type)
{
string connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
string strRowAffect;
SqlConnection con = new SqlConnection(connectionString);
try
{
con.Open();
}
catch (Exception e)
{
this.lstEventsOccurred.Items.Add("ERROR: Database Connection could not be established in callStoredProc(): " + fullPath);
this.lstEventsOccurred.Items.Add("Exception Produced: " + e.Message.ToString());
return -1;
}
SqlCommand command = new SqlCommand("the_StoredProcedureToCall", con);
command.CommandType = CommandType.StoredProcedure;
SqlParameter retVal = command.Parameters.Add("@Return_Code", SqlDbType.Int);
retVal.Direction = ParameterDirection.ReturnValue;
SqlParameter inputFileName = command.Parameters.Add("@InputFilePathName", SqlDbType.VarChar, 120);
inputFileName.Direction = ParameterDirection.Input;
inputFileName.Value = fullPath;
SqlParameter fileType = command.Parameters.Add("@FileType", SqlDbType.VarChar, 120);
fileType.Direction = ParameterDirection.Input;
fileType.Value = type;
this.lstEventsOccurred.Items.Add("Calling:" + command.ExecuteNonQuery().ToString());
strRowAffect = command.ExecuteNonQuery().ToString();
con.Close();
return (int)retVal.Value;
}
Something is incorrect and having the darndest time figuring it out.
Thanks in advance
|
|
|
|
|
First of all why are you returning -1 if there is no sql server available. Will your application work with no database?
Doesn't the return value have to be "@return_value" or something like that? Is that your issue?
Also, it you want to code this correctly try coding with "using" blocks. Using (conn = new sqlconnection()) etc...
Good luck.
I didn't get any requirements for the signature
|
|
|
|
|
the -1 is just an intercept if i cannot create a connection.
the return code from the stored proc will be a distinct value and never a -1 thus the -1 for the connection.
Can I use the ExecuteNonQuery() - Since i am only interested in the return code supplied.
Also it is my understanding the params need to be in a distinct order and defined?
I have changed the code around a little to...
For brevity i left the connection part out. Also i am 100% confimred the stored proc is working.
Another wrote that, but we tested extensively prior to implementing within this section of code.
And yes, if the DB cannot be connected this is ok.
SqlCommand command = new SqlCommand("the_storedProc", con);
command.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter();
param = command.Parameters.Add(new SqlParameter("@FilePath", SqlDbType.VarChar, 120));
param.Direction = ParameterDirection.Input;
param.Value = fullPath;
param = command.Parameters.Add(new SqlParameter("@FileType", SqlDbType.VarChar, 120));
param.Direction = ParameterDirection.Input;
param.Value = type;
param = command.Parameters.Add(new SqlParameter("@Return_cd", SqlDbType.Int, 8));
param.Direction = ParameterDirection.Output;
command.ExecuteNonQuery();
|
|
|
|
|
never mind i resolved the issue.
|
|
|
|
|
I have a little issue with the datasets in Visual Studio 2008. I am trying to do some reporting. I have created my datasets and they are linked to the Application Settings for the connection string to the SQL Server.
Well the problem is that I built my application to store that information in the registry. So it gets and sets the COnnection String in the Windows Registry.
So how do I specify those datasets to read from registry, or not even that, just get the information for the connection string from my RegistryAccess class I created? Which gets the connectionstring and returns the string?
|
|
|
|
|
Jacob D Dixon wrote: So it gets and sets the COnnection String in the Windows Registry
The most common place to store connection string information is in the config file, even has a special section for it, connectionStrings
Jacob D Dixon wrote: So how do I specify those datasets to read from registry
You don't specify this in the DataSet. DataSet is just the result from some other operation
only two letters away from being an asset
|
|
|
|
|
I'd like to extract a specific data from an HTML web page. I have created an XPath expression to do it for me.
The problem is that the HTML page is corrupted and the XmlDocument throws XmlException at me. How to make it working like a browser: ignore errors and continue loading? A free html cleaning lib might help, but I couldn't find anything useful.
Any help appreciated.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
|
Thanks for answering my post.
I tried both Tidy .NET and Tidy COM but they didn't satisfy me. I prefer Html Agility Pack suggested by Bruce.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
You might try using the HTML Agility Pack[^].
It's worked reasonably well for me in the past.
"Walking on water and developing software from a specification are easy if both are frozen." - Edward V. Berard
|
|
|
|
|
Thank you. It works fine.
I have another question.
Well, I want to make a simple word translator using an existing online dictionary (for my home use). The dictionary's homepage is http://www2.ling.pl[^]. The home page can be read successfuly.
However, ling.pl has a nice feature: you can access the dictionary by typing a word after "/". For example http://www2.ling.pl/do[^] would naviagate straight to the "do" word definition. Unfortuantely,
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
throws 404 error. Any ideas how to fix that?
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
hi
How can I call delegate
such As
private void button1_Click(object sender, EventArgs e)
I want to call button click delegate from another method
how can I do that
and thanks
|
|
|
|
|
Actually that's a method you would call so for example:
button1_Click(this, new System.EventArgs());
However, often the need to call button click from code is a symptom from a design issue.
It would be better if you create a new method and place the logic needed in that method. Button click only calls this method as does your code whenever that logic is needed. This method can be placed in the form itself or to a separate controller class.
|
|
|
|