출처: http://scn.sap.com/thread/1832712

크리스탈 리포트에서 서브리포트를 사용할 경우

서브 리포트에 하이퍼링크가 설정되어 있다.

이것을 제거하기 위해서 CrystalReportViewer에서 EnableDrillDown을 false로 변경하면 된다.

역시 구글..

CrystalReportViewer1

EnableDrillDown = False 


Posted by 노을지기

ASP.NET에서 gridview 데이터를 excel 파일로 출력하는 소스이다.



protected void btnExportToExcel_Click(object sender, EventArgs e)
{
    exportToExcel(gvData);
}

private void exportToExcel(GridView gv)
{
    Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition""attachment;filename=MyFiles.xls");
Response.Charset = ""; this.EnableViewState = false; StringWriter writer = new StringWriter(); HtmlTextWriter textWriter = new HtmlTextWriter(writer); gv.RenderControl(textWriter); Response.Write(writer.ToString()); Response.End(); } public override void VerifyRenderingInServerForm(Control control) { //You have to override this method (even with an empty method) //in order for GridView to be nested inside the Form control. //Otherwise you will receive the following error //Control 'gvData' of type 'GridView' must be placed inside a form tag with runat=server. }


마지막 반드시 VerifyRenderingInServerForm을 넣어주어야 한다.

없을 경우 에러 메시지ㅣ..


출처: http://www.geekcamp.us/articles/exporting_gridview_to_excel.aspx

참고: http://blogs.msdn.com/b/erikaehrli/archive/2009/01/30/how-to-export-data-to-excel-from-an-asp-net-application-avoid-the-file-format-differ-prompt.aspx


Posted by 노을지기

gridview 에서 데이터 포맷이다.

소수점 아래 3 자리수 지정을 하려고 한다.

{0:#,###.##0} 아래와 같은 양식을 사용하면 된다.


감사합니다.


출처: http://sammisoft.net/mboard/mboard/mboard.asp?exe=view&board_id=pds&group_name=sammisoft&idx_num=193&page=6&search_category=&search_word=&category=0&order_c=bd_idx_num&order_da=desc

[환경 : .net 2005, 웹사이트 개발]

 



 

 

GridView 컨트롤에서 열 편집으로 가면, 각 열의 데이터 포멧 형식을 지정할 수 있다. 

 

 

DataFormatString Example

 

{0:c} : interger와 같은 숫자 형식을 금액형식으로 출력한다. 접속 환경에 따라 \ 혹은 $가 될 수 있다고 한다.

\12.120.000

{0:#,###.##} : 천단위 혹은 소수점까지 출력하고자 할때 쓴다.

12,000.01

{0:d} : SmallDataTime형식은 년,월,일,시간까지 출력된다. 이를 시간을 제외한 날짜까지 출력하고자 할때 쓴다.

2007-07-07 12:01:01 -> 2007-07-07

그 외의 Date형식 바꾸기

 

d 2003-02-20
D 2003년 2월 20일 목요일
f 2003년 2월 20일 목요일 오후 1:29
F 2003년 2월 20일 목요일 오후 1:29:24
g 2003-02-20 오후 1:29
G 2003-02-20 오후 1:29:24
m 혹은 M 2월 20일
r 혹은 R Thu, 20 Feb 2003 13:29:24 GMT
s 2003-02-20T13:29:24
t 오후 1:29
T 오후 1:29:24
u 2003-02-20 13:29:24Z
U 2003년 2월 20일 목요일 오전 4:29:24
y 혹은 Y 2003년 2월


Posted by 노을지기

ASP.NET으로 이것 저것 하고 있는데, 기능 찾는데 시간이 너무 오래 걸린다.

GridView에서 insert 기능이 지원이 안되어, detailsview을 이용하여 작성하고 있다.


key을 이용하여 여러 gridview 데이터를 바인딩해야하는데, 변수를 사용하니 귀차니즘이 많다.

그래서 control 이벤트를 이용하여 사용하는데, datakey 값이 필요하였다.


출처: hhttp://forums.asp.net/p/1181584/2006420.aspx


protected void sdsSuppliers_Inserted(object sender, SqlDataSourceStatusEventArgs e)
{
       
if (e.Exception == null)
       
{
                lblShipperId
.Text = String.Concat("New ShipperID: ", e.Command.Parameters["@ShipperID"].Value);
       
}
}


Posted by 노을지기

출처: http://mimor.be/2011/asp-net-gridview-to-display-detailsview-on-other-page/


다른 페이지에서 사용하기


Double click the GridView item in your GUI.
You’ll get something as:

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged

End Sub

Now add the following code (note that this is in vb, so if you use C#, adjust the syntax)

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
           Response.Redirect("DetailsView.aspx?ID=" & GridView1.SelectedValue)
End Sub

You might also want to add or modify some lines in your sqlDatasource (of the destination page) to match these lines.
This way you’ll see the DetailView of the item you clicked in the GridView.

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
 SelectCommand="SELECT * FROM [Tablename]where [ID] = @ID"
<SelectParameters>
 <asp:QueryStringParameter QueryStringField="ID" name="ID" />
 </SelectParameters>
 </asp:SqlDataSource>


Posted by 노을지기