|
try this:
DropDownList2.DataSource = ds1.Tables["dept"];
DropDownList2.DataTextField = "DEPARTMENT";//the col which you want to display
DropDownList2.DataValueField = "";//DEPARTMENT id or anything else
DropDownList2.DataBind();
|
|
|
|
|
I have windows app and am using c#. I want to launch default browser from c# program and pass some parameters. Basically what i have is content type (eg. "application/msword") and byte array of content (word/excel/pdf docs in byte array). I want to pass these two parameters to browser and let it open the doc. Can anybody please guide me to achieve this? One more thing i don't want to create any file in local disk.
Thanks.
|
|
|
|
|
Are you saying the document is not on your disk or some remote machine, but in memory? If yes, simply save it to a temporary location and display it from there. That is what even browsers do.
Once you've saved it, try Process.Start("URL of your document") . That will open the default handler (generally, MS Word) though. Launching a local .DOC file with your default browser might be slightly more complicated, and I'm not even sure why you'd want to do that.
Cheers,
Vikram. (Proud to have finally cracked a CCC!)
|
|
|
|
|
Thanks Vikram, here are my problems:
1. I actually don't want to store doc in local machine and handle creation and deletion of files. If in any case end user have very minimum rights i may not be able to create file even. Here maybe i should think of memory stream?
2. "Launching a local .DOC file with your default browser might be slightly more complicated, and I'm not even sure why you'd want to do that. " i din't get this? Are you suggesting to launch directly ms word, excel or acrobat softwares and display docs in them instead of using browser? if yes, the problem with this approach is i need to know and code for all types of docs, if i use browser i no need to bother about this as far as i supply content type and byte array.
Thanks.
|
|
|
|
|
Member 2324483 wrote: If in any case end user have very minimum rights i may not be able to create file even. Here maybe i should think of memory stream?
AFAIK, *every* user will have read + write access to a temp directory. Path.GetTempPath() is your friend. I doubt Word can handle in-memory files.
Member 2324483 wrote: Are you suggesting to launch directly ms word, excel or acrobat softwares and display docs in them instead of using browser? if yes, the problem with this approach is i need to know and code for all types of docs, if i use browser i no need to bother about this as far as i supply content type and byte array.
Yes, that's what I suggest and it's the cleanest and the easiest. You don't have to handle any extra types, Process.Start("yourfile") will open it with the default program. It's opening with the default browser that is dubious.
Cheers,
Vikram. (Proud to have finally cracked a CCC!)
|
|
|
|
|
Hey..
i am doin a project where i will use a mouse effect like following:
i have a form. i want to so an effect that when user try to move it will move and tyhe opacity will become 30%.when the user leave the form the opacity of the form will become 100%.Just Like - when an exception occures in Visual Studio and a message form comes in front what can be move by mouse and reduces the opacity.
can anyone give the solution. Should i use "Event Move()"?
code segment will help me a lot.
Thanks .
Mahbub-E-Rabbani [TAFIN]
Bangladesh
|
|
|
|
|
Hi,
I"m currently designing reports for my company (yeah ) and I'm trying to define my datasets using xsd files in VS 2008 design time. I'm creating table adapters and providing the select queries which in turn populates my tables. I need to know if there is a way for me to pass parameters to the queries that I use in those table adapters without having to resort to runtime code (In other words in design-time in the form of a placeholder of some sort) and at a later stage pass that parameter from another class instance.
In code you would do:
SqlCommand Cmd = ....;
SqlParameter par1 = new SqlParameter();
...//Set all the parameter properties
Cmd.Parameters.Add(par1);
I'll consider runtime code if it happens in the dataset's code behind file. My reporting solution (XtraReports) works quite well with xsd datasets and designing a report mostly in design time is far less time consuming than doing all the databinding in the code behind. Can anybody plz help?
Regards
Jacobus
|
|
|
|
|
i have one file of
Type=Wave(Microsoft)
Format= mpeg layer-3
Audio=20kb/s,11025 hz,mono
times=10:04:31.909
///////////////////
directshow get me wrong time and cant seek by samples
mcisendstring get me wrong time too and can seek by samples but wrong
just sony Sound Forg Application can play it and get me true time and can seek and get me count of samples .
now i dont have idea for play this file and seek by samples.
if u have any way solve my problem .
i want to play this file and seek by samples.
|
|
|
|
|
da1.Fill(ds1,"group");
DataTable dt1 = ds1.Tables["group"];
da1 is a data adapter and ds1 is dataset.I wrote a code for binding to dropdownlist and it is working fine.I saw a code demo,dat's why i gave that "group" parameter.But i cannot understand it's use...n also it is not again used anywhere else in the code...What is that parameter actually?
|
|
|
|
|
Object browser would have told you that. Anyways, that is the name of the table in the dataset. You can refer to a table in the dataset through the index or by the name.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
i assumed that,that it should be the name of the table in the dataset.....But we are again creating a datatable dt1..are we assigning the value of the datatable,group,to dt1?And if i want to create one more table,patient,in teh same dataset will
da1.Fill(ds1,"patients");
DataTable dt2 = ds1.Tables["patients"];work?????????
|
|
|
|
|
|
Hi,
first of all: Don't cross post.
As already mentioned in the ASP.NET forum you have to use brackets in the correct way:
INSERT INTO Registration [DATE OF BIRTH], [CONTACT NUMBER] VALUES (...
Did you really use coulmn names with whitespace within your db? You should either use camelcase or underscore to seperate the words. And pay attention to sql injection (within your values). Search google for prepared statements.
Regards
Sebastian
|
|
|
|
|
INSERT INTO Registration ([DATE OF BIRTH], [CONTACT NUMBER]) VALUES ('" + DateT.Text + "','" + ContactT.Text + "')
Now look at parameters[^] to make your code more secure!
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Why are you posting same thing on different forums....
Be an Eagle, Sky is Yours.
|
|
|
|
|
In addition to all the advice you've been given, please pick a relevant subject. This is the C# forum after all, can you imagine what it would look like if every thread were to have the subject "C#" ?
Cheers,
Vikram. (Proud to have finally cracked a CCC!)
|
|
|
|
|
Hi All,
I'm working on a project where on the left hand side of the form i have a treeview control and bottom to that i have some buttons. When user clicks on the node then i'm loading respective user control on to the right hand side of the form.
The issue here is i have two save buttons one on user control and other on the main form just below the treeview control. I have the code to capture the key press :
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.S))
{
MessageBox.Show("Do Something");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
Here this code works only for the main form but not for the user control.
Please let me know how can i capture the key press event for usercontrol so that i can call save event of usercontrol.
Thanks in Advance
Regards,
Prakash N
|
|
|
|
|
Set the property KeyPreview in main form to true, then you can get always the event "KeyDown".
|
|
|
|
|
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
string connection1 = ConfigurationManager.AppSettings["conn"];
OleDbConnection con1 = new OleDbConnection(connection1);
con1.Open();
OleDbDataReader dr;
string query = "select DISTINCT DEPARTMENT from TIME_DETAILS ";
//OleDbDataAdapter da1 = new OleDbDataAdapter(query,con1);
//DataSet ds1 = new DataSet();
//da1.Fill(ds1);
OleDbCommand cmd = new OleDbCommand(query,con1);
dr = cmd.ExecuteReader();
while (dr.Read())
{
DropDownList2.Items.Add(dr[0].ToString());
DropDownList2.DataValueField.Insert(dr[0]);
}
}
|
|
|
|
|
what is the error you are getting... please specify in which line of code the error occurs... this will help our experts to help you better....
|
|
|
|
|
there is no error but the values r not shown in the drop down list
|
|
|
|
|
Have you tried below posted code...
Be an Eagle, Sky is Yours.
|
|
|
|
|
thnx sir i got it now....
|
|
|
|
|
Instead of
ankitjain1110 wrote: while (dr.Read())
{
DropDownList2.Items.Add(dr[0].ToString());
DropDownList2.DataValueField.Insert(dr[0]);
}
Use this
DropDownList2.Items.Add(New ListItem(dr[0].ToString(),dr[0].ToString());
Be an Eagle, Sky is Yours.
|
|
|
|
|
this thing is showing an error like ")expected"
|
|
|
|