|
Hi everyone,
Im using c# asp.net 2.0. In a dataset im having one column value as either 0 or 1,if the row value is 1 means the checkbox should be checked and its 0 means the checkbox should be unchecked in the gridview,im having the checkbox column as a template column.im having one checkbox column.How should i achieve this..
regards
Kanna..
|
|
|
|
|
Put one more label in this checkbox column. the DataField of this label should be mapped to the actual field from database.
In Item_DataBound() event of GridView, you can check whether the value is 0 or 1. then, find the checked box control and check or uncheck based on the value..
Eg: Item_DataBound Event
Label lbl = (Label)e.FindControl("lblValue");<br />
CheckedBox chk = (CheckedBox)e.FindControl("chkCheckedBox");<br />
chk = (lbl.Text == "1") ?? true:false;<br />
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
just bind data as other columns. But the Column u want to be in checkbox should be of datatype 'Bit' in database.
|
|
|
|
|
how to populate data in a datadridview through programs
shashank
|
|
|
|
|
<br />
string strSQLconnection = "Data Source=dbServer;Initial Catalog=testDB;Integrated Security=True";<br />
SqlConnection sqlConnection = new SqlConnection(strSQLconnection);<br />
SqlCommand sqlCommand = new SqlCommand("select * from table1", sqlConnection);<br />
sqlConnection.Open();<br />
<br />
SqlDataReader reader = sqlCommand.ExecuteReader();<br />
GridView1.DataSource = reader;<br />
GridView1.DataBind();
Ref: How to populate DataGridView, GridView with SQL statement in C#
More .....[^]
Hope it helps..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
shashankshekhar wrote: how to populate data in a datadridview through programs
By using Google[^]
Cheers,
Vıkram.
Be yourself, no matter what they say.
- Sting, Englishman in New York.
|
|
|
|
|
Hai All,
I am having my first work in generating hipaa edi streams, validating edi streams using XML schema!Could anyone please tell me some ideas to do this? This is my first work, so i have to do more careful, It will be really thankful,if you help me! please help me!
i have to finish this work in C#.net! Please help me!
|
|
|
|
|
Hello
I have to search a string "AssemblyVersion" and if i get this string i have to comment it, and also add comment in front of this string ,
if this string is already commented then it will not comment again...
I have to search this string in Assemblyinfo.cs file and this file is in different project.
How do i Solve this problem?
If anyone know that how to search the string and comment it then plz tell me as soon as
Thanks in Advance..
-- modified at 0:30 Thursday 30th August, 2007
|
|
|
|
|
Hi,
Open the file usual but give right the path and search with regex.
hope this help.
|
|
|
|
|
Is there a way to have StreamReader start reading a file from the end? I know there is no method, but is there some type of way using the stream class?
I have some large files where the data that needs to be gathered is at the very end and looking to cut down on the processing time.
BTW using 1.1
Jude
|
|
|
|
|
What about using FileStream.Seek?
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
I am having trouble with closing a form created in a seperate thread. This is what I am trying to accomplish: I have a program that runs in the taskbar. When a user double-clicks a key, a form is created in a new thread and is shown on top of all other forms. When the user clicks anywhere outside the form, the thread will close, but the program will continue to run in the background. This is similar to the Google Desktop functionality. The code works the first time the form is created in a new thread, but if the form has been closed once, you have to click on the form to make it active and then click outside of it before it will close. I have tried using the Deactivate and LostFocus events, but they both only work the first time the form is shown. Any suggestions would be greatful. I have included a snippet of code below.
<br />
public class MyClass {<br />
private Thread _thread;<br />
private FMain _fmain;<br />
private UserActivityHook _keyhook;<br />
<br />
public MyClass() {<br />
_keyhook = new UserActivityHook(false, true);<br />
_keyhook += new KeyEventHandler(KeyDoubleClick);<br />
}<br />
<br />
private void KeyDoubleClick(object sender, KeyEventArgs e) {<br />
if (e.KeyValue == 163) {<br />
_thread = new Thread(new ThreadStart(OpenForm));<br />
_thread.Start();<br />
}<br />
}<br />
<br />
private void OpenForm() {<br />
_fmain = new FMain();<br />
_fmain.Deactivate += new EventHandler(form_Close);<br />
_fmain.LostFocus += new EventHandler(form_Close);<br />
_fmain.ShowDialog();<br />
}<br />
<br />
private void form_Close(object sender, EventArgs e) {<br />
_thread.Abort();<br />
}<br />
}<br />
References: The UserActivityHook was fortunately posted by George Mamaladze; http://www.codeproject.com/csharp/globalhook.asp[^]
|
|
|
|
|
I don't think you need to close the form. Why don't you just hide the form when it is deactivated and show the form when it is activated?
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Thank you for the suggestion. My problem though is trying to get the form to Hide/Close once the user clicks/types outside the form. Is there an event fired when this happens that I am not aware of or do I need to use a global hook? If I was to use a hook, how do I know that the source of the hook was not within the form?
|
|
|
|
|
What about Deactivate event of form?
private void Form1_Deactivate(object sender, EventArgs e)<br />
{<br />
this.Hide (); <br />
}
I think that this "Deactivate" event is good enough. I dont think you need to use Window Hooking.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
you might be able to use .ActiveForm.Close() if you call it from the same thread which generated(showed) the form, else you'll get a "cross-thread exception"
Is this form some type of information "pop-up" ? if so you could just call .Show() and then set a timer to call the .ActiveFrom.Close() on it. Also keep your current if you click on it and then click away it closes.
This would be a better user experience, as they don't have to keep clicking away close the dialog.
another problem is that you are calling abort() to your thread and not allowing it to exit cleanly
All threads should include a method to stop their execution loop, .abort() is to throw an exception on a soft-locked thread. A situation where you know that it should have quit already but it is stuck in some loop.
The exception doesn't allow the thread to finish its task. Think what will happen if a thread was in the middle of saving some file that was only 1/2 written when it was aborted.
|
|
|
|
|
m working on the student management software on c#2005 and sql 2005 , i need to take backup of database " any session" from my application and also save it to the cd. i made differnt database for all session( for Example session07-08, session08-09) so if i want to take backup of sessiono7-08 from my c# application than
<<tech-prog>>
|
|
|
|
|
The below quick function will back up a database
public void BackupDataBase(string databaseName,string Path)
{
string backUpQuery = "USE MASTER"+
"EXEC sp_addumpdevice 'disk', 'MyTestDatabase',"+ path+databaseName+".bak"+
"BACKUP DATABASE "+ databaseName +"TO MyTestDatabase";
SqlConnection con = new SqlConenction(connectionString);
con.Open();
SqlCommand cmd=new SqlCommand(backUpQuery,con);
cmd.ExecuteNonQuery();
}
Please modify the same as required.
laddie
|
|
|
|
|
thanks
but cud you plz tell waht i write instead of 'disk' and MyTestDatabase'
<<tech-prog>>
|
|
|
|
|
Could someone possibly please show me an example, even if it's a parametized query how I can insert into multiple tables.
I have a new employees form with name, role, manager, division, skills, applications. The employee table only has the employeeID primary key, firstname, lastname and then all the foreign key id's for the other tables. The other tables have the other info like description etc.
If I'm creating a new employee, I obviously want them all to update based on the same employee and then the ID's to automatically insert based on the pf fk relationship.
I have searched on google but I can only find examples where you insert one at a time, which works but its not related to the employeei have entered.
Thank you so much
|
|
|
|
|
betetr you use trigers (insert) to insert data in all table based on the employee table
<<tech-prog>>
|
|
|
|
|
Thanks. I'm after any example you can give me. Could you possibly give me an example. I tried the following but the whole injection attack thing. I think the ands could be wrog. Please feel free to
string sql = "INSERT INTO employees(Firstname,Lastname) Values ('" + FirsttextBox.Text.ToString() + "' , '" + LasttextBox.Text.ToString() + "' and Insert into Role (Role) Values ('" + RolecomboBox1.Text.ToString() + "')Insert into Manager (MFirstname) Values ('" + ManagercomboBox1.Text.ToString() + "') Insert into Division (DivisionName) Values ('" + DivisioncomboBox1.Text.ToString() + "')";

|
|
|
|
|
A trigger may not always be the best solution. You have to look at performance and other aspects also.
only two letters away from being an asset
|
|
|
|
|
Your best solution would be to create a stored procedure and call it within your code "ExecuteNonQuery." The stored procedure will do all the work of inserting the records into the proper tables. As far as I know, there is not a way, with SQL Server, to insert into multiple tables with one INSERT statement. This also gives you the ability to do error checking on the back-end.
|
|
|
|
|
Thanks, I do have the statement in the nonexecutequery block already.
Is it possible to give me a little exampypoos???;)
|
|
|
|