|
The Databind is a method for the gridview for Asp .Net and databindings is to assign data to a control (this is usually a field value)
So remove the databindings line.
Are you sure that your dataset is getting populated?
Try running into debug mode and check the contents of your dataset before you set the data source of the gridview.
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
ya i checked my dataset, its populated.
but datagridview is empty
kssk
|
|
|
|
|
hi ,
if i may ask, what code your are writing for retrieval ?
if ur dataset is getting populated, then use : DataGridVw1.DataSource=ds.Tables[0];
and remove the data bindings line. and then check ?
|
|
|
|
|
Printing data in C#.NET from webbrowser used on windows form.
No other data will be printed except webbrowser
|
|
|
|
|
Hi, I have requirement like this..
I have one windows form which contains datagrid which displays the data.
And another button is there outside of grid in winform. If i click on button, the datagrid has to be printed...
so, i need to call window.print() in button click..
Ho can i call javascript in button click.
Thanks in advance
|
|
|
|
|
I have also faced the same situation i solved this by calling
Page_ClientValidate() function before printing. Don't directly call
window.print() instead
<br />
<br />
private void Page_Load(object sender, System.EventArgs e)<br />
{<br />
StringBuilder myScript = new StringBuilder();<br />
<br />
myScript.Append("<script language='Javascript'>");<br />
myScript.Append(" function PrintForm(){");<br />
myScript.Append(" if (Page_ClientValidate()){");<br />
myScript.Append(" window.print();}");<br />
myScript.Append("}");<br />
myScript.Append("</script>");<br />
<br />
this.RegisterStartupScript("MyScript", myScript.ToString());<br />
<br />
Button2.Attributes.Add("onclick","javascript:PrintForm();");<br />
}<br />
<br />
this should help.
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
My Requirement is in Windows form..not in webform.
In windows, we dont have Page_load , REgisterclientscriptblock etc..
Can u suggest me regarding windows form..
|
|
|
|
|
Hi,
you can check this...
Link1[^]
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
Hi,
The code here is working very good when the ForBorderStyle is NOT set to "None":
http://www.codeproject.com/KB/vb/SnapForm.aspx
In my application, it's set to None... And I move the form by holding down the right mouse button and moving it. The code still partially work, but when I approach the taskbar from the clock side it's not completely sticked to the corners.
I tried to figure out what wrong with code but no luck (and no experience).
The complete code is attached. Just create a new project and paste it.
Your help would be greatly appreciated.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication11
{
public partial class Form1 : Form
{
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
# region SnapToDesktopBorder
private const int mSnapOffset = 35;
private const int WM_WINDOWPOSCHANGING = 70;
[StructLayout(LayoutKind.Sequential)]
public struct WINDOWPOS
{
public IntPtr hwnd;
public IntPtr hwndInsertAfter;
public int x;
public int y;
public int cx;
public int cy;
public int flags;
}
protected override void WndProc(ref Message m)
{
// Listen for operating system messages
switch (m.Msg)
{
case WM_WINDOWPOSCHANGING:
{
SnapToDesktopBorder(this, m.LParam, 0);
}
break;
}
base.WndProc(ref m);
}
public static void SnapToDesktopBorder(Form clientForm, IntPtr LParam, int widthAdjustment)
{
if (clientForm == null)
{
// Satisfies rule: Validate parameters
throw new ArgumentNullException("clientForm");
}
// Snap client to the top, left, bottom or right desktop border
// as the form is moved near that border.
try
{
// Marshal the LPARAM value which is a WINDOWPOS struct
WINDOWPOS NewPosition = new WINDOWPOS();
NewPosition = (WINDOWPOS)System.Runtime.InteropServices.Marshal.PtrToStructure(LParam, typeof(WINDOWPOS));
if (NewPosition.y == 0 || NewPosition.x == 0)
{
return;
// Nothing to do!
}
// Adjust the client size for borders and caption bar
Rectangle ClientRect = clientForm.RectangleToScreen(clientForm.ClientRectangle);
ClientRect.Width += SystemInformation.FrameBorderSize.Width - widthAdjustment;
ClientRect.Height += (SystemInformation.FrameBorderSize.Height + SystemInformation.CaptionHeight);
// Now get the screen working area (without taskbar)
Rectangle WorkingRect = Screen.GetWorkingArea(clientForm.ClientRectangle);
// Left border
if (NewPosition.x >= WorkingRect.X - mSnapOffset && NewPosition.x <= WorkingRect.X + mSnapOffset)
{
NewPosition.x = WorkingRect.X;
}
// Get screen bounds and taskbar height
// (when taskbar is horizontal)
Rectangle ScreenRect = Screen.GetBounds(Screen.PrimaryScreen.Bounds);
int TaskbarHeight = ScreenRect.Height - WorkingRect.Height;
// Top border (check if taskbar is on top
// or bottom via WorkingRect.Y)
if (NewPosition.y >= -mSnapOffset && (WorkingRect.Y > 0 && NewPosition.y <= (TaskbarHeight + mSnapOffset)) || (WorkingRect.Y <= 0 && NewPosition.y <= (mSnapOffset)))
{
if (TaskbarHeight > 0)
{
NewPosition.y = WorkingRect.Y;
// Horizontal Taskbar
}
else
{
NewPosition.y = 0;
// Vertical Taskbar
}
}
// Right border
if (NewPosition.x + ClientRect.Width <= WorkingRect.Right + mSnapOffset && NewPosition.x + ClientRect.Width >= WorkingRect.Right - mSnapOffset)
{
NewPosition.x = WorkingRect.Right - (ClientRect.Width + SystemInformation.FrameBorderSize.Width);
}
// Bottom border
if (NewPosition.y + ClientRect.Height <= WorkingRect.Bottom + mSnapOffset && NewPosition.y + ClientRect.Height >= WorkingRect.Bottom - mSnapOffset)
{
NewPosition.y = WorkingRect.Bottom - (ClientRect.Height + SystemInformation.FrameBorderSize.Height);
}
// Marshal it back
System.Runtime.InteropServices.Marshal.StructureToPtr(NewPosition, LParam, true);
}
catch (ArgumentException ex)
{
}
}
# endregion
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
}
}
|
|
|
|
|
Hi,
Is it possible to record the voice from phone using tapi with C#.Net ?
Thanks,
Gopal.S
|
|
|
|
|
Yes.
SSK.
Anyone who says sunshine brings happiness has never danced in the rain.
|
|
|
|
|
Hi,
Thanks for your reply. Could you send any sample or material links for this one?
Regards,
Gopal.S
|
|
|
|
|
|
Hi friends...
is it possible to have a datagrid with multiple header?
i want to generate a report in datagrid.
the form should be like this
Heading 1 | Heading 2| Heading 3 | Main Heading
-----------|-----------|-----------|
Sh1 | Sh2 | Sh1 | Sh2 |SH1 | Sh 2 |Sub Heading
----|------|-----|-----|----|------|
|Rows......
-----------------------------------|
how is it done?
somebody plz help me....
|
|
|
|
|
|
I want to store the edit position of a richtextbox and set the position back after I renewed it's contents.
Thanks.
|
|
|
|
|
I believe the SelectionStart property stores where the caret is, if there's no selection.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
OK; I tried ClickOnce, and that didn't work. How would I send a program with some DirectX and audio files in an eMail? Thanks.
- I love D-flat!
|
|
|
|
|
* In a zip file
* In a self extracting zip file
* As an MSI file
* as a link to a download
A lot of corporate mail systems will block attachments that it sees as dangerous. So EXEs and MSI files prossibly won't get through. ZIP files are also often searched by email scanners so if those files are found in there also it will get blocked.
|
|
|
|
|
Well, I see, but every time I send, it always says I'm missing files (or, the other person sees that...). So is there anything I need to include?
- I love D-flat!
|
|
|
|
|
Well, your first step would be to make sure the person on the other end has DirectX and .NET installed. Then zip up the files from the directory where you run them ( so they are in the right folders ), rename the zip to zip1 or something if need be ( to avoid it being rejected ) and send
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Is there anyway to add that to the packge, because I'm pretty sure they don't have anything that I do with resources.
*Also, to let people know, I hope to find a true programming class within a year or two, so I can finally get REALLY going.
- I love D-flat!
|
|
|
|
|
I am writing an HR application to add new employees. Currently, I am having an issue where I want to send a specific message base on the exception that is received. In my database SNN is a unique key hence if an SSN is being added that already exist in the DB a Unique key violation exception is thrown. If the UserID already exist a Primary Key violation exception is thrown. I am certain this is possible but just not sure what is best practice. I can write a method which search the DB first and if the record is found thrown an error message based on whether it was the Unique key violation or the PK violation. I have also been searching MSDN to see if I can identify the C# SqlClient error ID for either scenarios and based on the exception ID, alert the user with the right error message.
Any advice will be greatly appreciated.
Skan
If you knew it would not compile why didn't you tell me?!?!?!
|
|
|
|
|
Skanless wrote: I have also been searching MSDN to see if I can identify the C# SqlClient error ID for either scenarios and based on the exception ID, alert the user with the right error message
All the Ids can be found in SQL Server itself.
SELECT * FROM sys.messages or
SELECT * FROM sysmessages (if you are on SQL Server 2000)
|
|
|
|
|
Thanks dude, I found them. I would still like to know what best practice for a situation like this.
Skan
If you knew it would not compile why didn't you tell me?!?!?!
|
|
|
|