|
how to write a event for a dynamically created controll in C#,
For Example i have created a combo box, Check Box dynamically in C#,
when a User Select a item from combo box, it will will show which item he has selected using a message Box.
Please help me out.
burhan
|
|
|
|
|
Suppose myCombo is the name of your dynamically created control....then add a Event handler like this....
myCombo .SelectedIndexChanged += new System.EventHandler(this.cmbDynamicNameCombo_SelectedIndexChanged);
Now put your code in cmbDynamicNameCombo_SelectedIndexChanged
Tirtha
Miles to go before I sleep
|
|
|
|
|
Hi All,
I work on Crystal Report for .Net. with Asp.net 2005.
How can I Open Crystal Report in PDF format in Browser Window.
in Other word m when I click print button automaticaly Open the Report in pdf format in the browser.
Ala Qunaibi
Ala Qunaibi
|
|
|
|
|
Its something like export crystal report to pdf.Try this:
On Export Button Click:
private void Button1_Click(object sender, System.EventArgs e)
{
MemoryStream oStream; // using System.IO
oStream = (MemoryStream)
report.ExportToStream(
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(oStream.ToArray());
Response.End();
}
|
|
|
|
|
Thanks , it is work in successfully,
But , There are problem in arabic character, how can I determine unicode for arabic charater and hindi numbers
Ala Qunaibi
Ala Qunaibi
|
|
|
|
|
Well even I dont know how to do this u can search on net.But it might be something Culture Information.Not sure...
|
|
|
|
|
Thanks .
Ala Qunaibi
|
|
|
|
|
Hi All,
I need Export the gridview to excel.When I click the Export button it should open the save dailog and user should give file name and path or it should take the filename with path. Anyway will do and it is save there.
Thanks in advance...
|
|
|
|
|
GridView does not have direct functionality to export data into Excel, so you would need to add extra efforts on your side to do this job.
There are several ways to export data into Excel and preserve format
1. Use Jet OLEDB Provider. You need to create INSERT SQL statements and loop through the rows of the grid to insert records one by one. But in this case you need to convert your column from numeric data type to string one.
2. Use Microsoft Office Tools for .NET. This way is slower, but gives you more functionality and allows formatting of the data. It allows you to control your output, but could be very slow and you need to pay attention to releasing all the resources associated with it, because it is COM-based.
3. Write code that stores data into CSV or HTML. Those formats recognized by Excel and should preserve formatting
4. Use third party components like Ajax, that could provide desired functionality
Regards,
Satips.
|
|
|
|
|
Hi Satips,
Thanks for the reply.
I got some code from Google.Its working fine.The only thing is that I need to save it on the server and filename should be given by me not by user.Following is the code:
On Export Button Click:
Dim attachment As String = "attachment; filename=Contacts.xls"
Response.ClearContent()
Response.AddHeader("content-disposition", attachment)
Response.ContentType = "application/ms-excel"
Dim sw As StringWriter = New StringWriter()
Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)
gvExport.RenderControl(htw)
Response.Write(sw.ToString())
Response.End()
This throws HttpException so I need to add this:
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
Now I just need to save it on server.
Can u please tell how do I do??
Thanks in advance...
|
|
|
|
|
hi,
just gothrough this link for popluating data from dataset to Excel sheet
|
|
|
|
|
Sorry No link found
|
|
|
|
|
see this link
ok
www.msdn2.microsoft.com/en-us/library/aa159891(office.11).aspx
|
|
|
|
|
sorry page cannot be displayed.......
|
|
|
|
|
http://msdn2.microsoft.com/en-us/library/aa159891(offices.11).aspx
|
|
|
|
|
plz explain .dll hell in .net
|
|
|
|
|
plz refer this link..
http://en.wikipedia.org/wiki/DLL_hell
In computing, DLL hell is a phrase for complications which arise when working with dynamic link libraries, or DLLs.
DLL hell encompasses the difficulties of managing dynamic-link libraries (DLLs) in Microsoft Windows operating systems. These difficulties include conflicts between DLL versions, difficulty in obtaining required DLLs, and having many unnecessary DLL copies.
|
|
|
|
|
|
hi guys
i would like to retrive the data of One cell of the sql database's table
i already know the command will be like this:
select age from kids where nric = 'sss'
this command statement would retrive only 1 result
however i dont know the sysntex to use this command statment with in asp.net (c# coding side)
could anyone show me how it is done pls?
|
|
|
|
|
sqlconnection conn = new sqlconnection(path of the connection);
sqlcommand cmd = new sqlcomand("your query", connection);
string result;
result=cmd.executescalar();
Gautham
|
|
|
|
|
it says
Error 51 The type or namespace name 'sqlconnection' could not be found (are you missing a using directive or an assembly reference?)
|
|
|
|
|
be sure to import System.Data.SqlClient NameSpace
Tirtha
Miles to go before I sleep
|
|
|
|
|
i already added
using System.Data.SqlClient;
if this is not correct pls kindly describe what i shld do pls
|
|
|
|
|
hi ..
here is some code for connecting to database..
i think this would help you.. make necessary changes..
this is just to show you how we can connect to the db..
put connection string in web.config file
using System;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
public class dbClass
{
private SqlConnection con;
private SqlCommand com;
private SqlDataReader dr;
private SqlDataAdapter da;
private DataSet ds;
public dbClass()
{
con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["conString"].ToString());
}
///
/// Open an Sql connection.
///
/// <returns>sqlconnection
public SqlConnection GetConnection()
{
try
{
if (con.State == ConnectionState.Open)
{
con.Close();
}
con.Open();
}
catch (Exception ex)
{
string err = ex.Message.ToString();
}
return con;
}
///
/// Executes a query with SqlDataAdapter
///
/// <param name="sql" />sql query
/// <returns>DataTable
public DataTable GetAdapter(string sql)
{
try
{
com = new SqlCommand(sql, GetConnection());
com.CommandTimeout = 0;
da = new SqlDataAdapter(com);
ds = new DataSet();
da.Fill(ds);
return ds.Tables[0];
}
finally
{
con.Close();
}
}
|
|
|
|
|
hi
u can see this code and do it
string strCmd="select age from kids where nirc='sss'";
Sqlcommand cmd =new sqlCommand(strCmd,con);
cmd.CommandType=CommandType.Text;
con.open();
DataReader dr=cmd.ExecuteReader();
while(dr.read)
{
// code to populate data
example u want to populate to combo box then u can writecode like this
cmdAge.add.item(dr.GetValues[1]);
}
try with this code i hope u will come out of the problem
tell me confirm once
ok
|
|
|
|