|
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
Table tbl = e.Row.Parent as Table;
TableCell cell = new TableCell();
CheckBox chk = new CheckBox();
Label lbl2 = new Label();
HiddenField rowValue = new HiddenField();
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Visible = false;
}
else
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lbl = (Label)e.Row.FindControl("lblValue");
string str1 = ((Label)(lbl)).Text;
string prevStr= (string)Session["previousStr"];
if (prevStr== str1)
{
counter += 1;
}
else
{
prevStr= sr1 ;
Session["previousStr"] = prevStr;
counter = 1;
if (tbl != null)
{
GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
rowValue.ID = "hdnNumRows";
rowValue.Value = counter;
lbl2.Text = Convert.ToString(counter);
cell.ColumnSpan = this.GridView1.Columns.Count;
cell.Width = Unit.Percentage(100);
cell.BackColor = System.Drawing.Color.Aqua;
HtmlGenericControl span = new HtmlGenericControl("span");
span.InnerHtml = prevStr;
cell.Controls.Add(span);
cell.Controls.Add(chk);
cell.Controls.Add(lbl2);
cell.Controls.Add(rowValue);
row.Cells.Add(cell);
tbl.Rows.AddAt(tbl.Rows.Count - 1, row);
}
}
}
}
}
As you can see, I have a counter in both parts of my if statement. This is so that if the "if" part is true the counter goes up by one, else it is still one. When run this with JavaScript to show the results, it is fine, I am seeing 3, 2, 1, but when I try show this in a label, all I am seeing 1,1,1. Why?
|
|
|
|
|
Instead of doing this on webserver, why dont you do this in the SQL itself?
Add a new column, lets say DeptCount which would give you the count.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
The reason being is that I only want to show the count in my inserted row, the value of which I am going to use in my checkbox control to then hide or show the rows which the user checks the checkbox
|
|
|
|
|
hi friends
In my button click,i opened two browser window seperately,now i want to open the two tab in same browser window instead of open two window seperately(IE only)...
can any one help?
Known Is Drop.Unknown Is Ocean
|
|
|
|
|
No web technology knows about the Tabs. All it knows is the window.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
You can do a custom tab yourself, which can switch the pages in a window
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:50am.
|
|
|
|
|
used iframe in my webpage want to get url of the ifram , refresh the iframe, full screen the iframe
modified on Saturday, January 23, 2010 1:39 AM
|
|
|
|
|
Hi
I have list box where i written code on selectedindexchanged event in code behind. I also want to run java script on the same event or click event so that my code behind code also run with respected to java script.
I have written javascript for color changed of listbox selected item and on selected index changed I have written some database functionality.
Is it possible?? Or any other solution for that.
Thanks
|
|
|
|
|
Yes it is possible but remember that the SelectedIndexChanged event will cause a postback and the page will be re-rendered, wriping away any thing that was done by the JavaScript. Depending on what the action is or your expected results you could use an Ajax call rather than the traditional postback
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi Everybody,
I have aspx page in which there is one link. When user clicks on the link it should open a (Silver Light or normal) model dialogue box or popup with few checkbox options. As soon as user selects them and clicks the button. The information should be saved.
Can I use WPF or Silver Light model dialogue box in aspx page. Please help me in this regard. Atleast by some links. In this mean time I will try from my side with google uncle (nice uncle for any help) .
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
Seems you have a lot to learn and maybe you should do that before trying to continue. WPF and Silverlight are not interchangeable. WPF, which stands for WINDOWS Presentation Foundation, can't be used in a web application. Neither can you just create a Silverlight dialog and use it is a webpage.
There are several articles and resources available that discuss modal dialogs in a web application, they're not that difficult to find.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
I want to keep an HTML table with pagiing inside a ajax tab control for that I have written following code
This is ASPX code
<ajax:TabContainer ID="tabHomeownTips" runat="server"
ActiveTabIndex="0" Width="565px" Height="600px" Font-Underline="False"
Enabled="true" EnableTheming="True" ScrollBars="Auto" EnableViewState="False" >
<ajax:TabPanel ID="TabTip1" HeaderText="Tip1" runat="server" OnClientClick="function(){LoadTableTab('results','pageNavPosition');}">
<ContentTemplate>
<table id="results" >
<tr>
<th>Sr. No.</th>
<th>Description</th>
</tr>
<tr>
<td>1</td>
<td>Description of Tab1 Item 1</td>
</tr>
<tr>
<td>2</td>
<td>Description of Tab1 Item 2</td>
</tr>
<tr>
<td>3</td>
<td>Description of Tab1 Item 3</td>
</tr>
<tr>
<td>4</td>
<td>Description of Tab1 Item 4</td>
</tr>
<tr>
<td>5</td>
<td>Description of Tab1 Item 5</td>
</tr>
<tr>
<td>6</td>
<td>Description of Tab1 Item 6</td>
</tr>
</table>
<div id="pageNavPosition"></div>
</ContentTemplate>
</ajax:TabPanel>
<ajax:TabPanel ID="TabTip2" HeaderText="Tip2" runat="server" OnClientClick="function(){LoadTableTab('Table1','Div1');}">
<ContentTemplate>
<table id="Table1">
<tr>
<th>Sr. No.</th>
<th>Description</th>
</tr>
<tr>
<td>1</td>
<td>Description of Tab1 Item 1</td>
</tr>
<tr>
<td>2</td>
<td>Description of Tab1 Item 2</td>
</tr>
<tr>
<td>3</td>
<td>Description of Tab1 Item 3</td>
</tr>
<tr>
<td>4</td>
<td>Description of Tab1 Item 4</td>
</tr>
<tr>
<td>5</td>
<td>Description of Tab1 Item 5</td>
</tr>
<tr>
<td>6</td>
<td>Description of Tab1 Item 6</td>
</tr>
</table>
<div id="Div1"></div>
</ContentTemplate>
</ajax:TabPanel>
</ajax:TabContainer>
</pre>
This is Javascript code
function LoadTableTab(tblid,divid){
var pager = new Pager(tblid, 2);
pager.init();
pager.showPageNav('pager', divid);
pager.showPage(1);
}
function Pager(tableName, itemsPerPage) {
this.tableName = tableName;
this.itemsPerPage = itemsPerPage;
this.currentPage = 1;
this.pages = 0;
this.inited = false;
this.showRecords = function(from, to) {
var rows = document.getElementById(tableName).rows;
// i starts from 1 to skip table header row
for (var i = 1; i < rows.length; i++) {
if (i < from || i > to)
rows[i].style.display = 'none';
else
rows[i].style.display = '';
}
}
this.showPage = function(pageNumber) {
if (! this.inited) {
alert("not inited");
return;
}
var oldPageAnchor = document.getElementById('pg'+this.currentPage);
oldPageAnchor.className = 'pg-normal';
this.currentPage = pageNumber;
var newPageAnchor = document.getElementById('pg'+this.currentPage);
newPageAnchor.className = 'pg-selected';
var from = (pageNumber - 1) * itemsPerPage + 1;
var to = from + itemsPerPage - 1;
this.showRecords(from, to);
}
this.prev = function() {
if (this.currentPage > 1)
this.showPage(this.currentPage - 1);
}
this.next = function() {
if (this.currentPage < this.pages) {
this.showPage(this.currentPage + 1);
}
}
this.init = function() {
var rows = document.getElementById(tableName).rows;
var records = (rows.length - 1);
this.pages = Math.ceil(records / itemsPerPage);
this.inited = true;
}
this.showPageNav = function(pagerName, positionId) {
if (! this.inited) {
alert("not inited");
return;
}
var element = document.getElementById(positionId);
var pagerHtml = ' ';
for (var page = 1; page <= this.pages; page++)
{
if(page >1)
{
pagerHtml += ' | ';
}
pagerHtml += '<span id="pg' + page + '" class="pg-normal" onclick="' + pagerName + '.showPage(' + page + ');">' + page + '</span>';
pagerHtml += '';
}
element.innerHTML = pagerHtml;
}
}
I have tried this code in normal page it works fine but when I am using same code then Its giving me the Table in Paging section but whenever I am click on Page number I am getting error as 'pager' is undefined. What am I missing and How can I fix this bug to make it working in ajax tab control
Thanks
Rock Star
|
|
|
|
|
Hello,
I have created one crystal report. On the default.aspx page, i have added crystalreportsource and crystalreportviewer and set its report sources. Crystalreport.Printmode=Activex.
I want the output should come :
(A) On screen
(B) Directly to the client printer machine
simantenously. On client machines i have set Generic printer as default.
How do i get the output on page and directly on printer simantenously on clicking of a button.
Regards
Girish
|
|
|
|
|
Hi, Please change the System & Printer names based on yours.
code is below
ReportDocument rptPrint = new ReportDocument();
rptPrint.Load(Server.MapPath("Reports").ToString() + "\\rptSales.rpt");
DataSet dsData = (DataSet)Session["EmpData"];
rptPrint.SetDataSource(dsData);
CrystalReportViewer1.ReportSource = rptPrint;
CrystalReportViewer1.DataBind();
string strSystemName = "\\\\RAJA\\";
string strPrinterName = "SAMSUNG";
rptPrint.PrintOptions.PrinterName = strSystemName + strPrinterName;
rptPrint.PrintToPrinter(1, false, 0, 0);
rptPrint.Close();
rptPrint.Dispose(); Please let me know your feedback because i was posted a wrong link as answer for a question today in Quick Answers section.
Regards,
thatraja
|
|
|
|
|
Thanks for reply and your concern for answer. I just want to know how it will print on client machine using above code. I mean what should i write in :
string strSystemName = "\\\\RAJA\\";
string strPrinterName = "SAMSUNG";
Let me once again clear my question.
I need to send the crystal report output directly on different cleint machines, on clicking of a button. In the above example how do i get the strSystemName and strPrinterName for unknown client machines.
Regards
Girish Sharma
|
|
|
|
|
I'm sorry i forgot that,
System.Net.IPHostEntry host;
host = System.Net.Dns.GetHostEntry(Context.Request.ServerVariables["REMOTE_HOST"]);
string strSystemName = host.HostName; please let me know your feedback again & assume you have the solution. I'm upset from evening for a wrong answer to one question. So please try to make me happy.
Regards,
thatraja
|
|
|
|
|
Thanks again for your reply. I am using below code with one crystalreportviewer and one button control on web page.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ocn As New System.Data.OracleClient.OracleConnection
Dim oda As New System.Data.OracleClient.OracleDataAdapter("select empno,ename from emp", ocn)
Dim ods As New System.Data.DataSet()
ocn.ConnectionString = "Data Source=orcl;User ID=scott;Password=pw;Unicode=True"
oda.Fill(ods)
Dim rptprint As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
rptprint.Load(Server.MapPath("Reports").ToString() + "\\CrystalReport.rpt")
rptprint.SetDataSource(ods)
CrystalReportViewer1.ReportSource = rptprint
CrystalReportViewer1.DataBind()
''rptprint.PrintOptions.PrinterName = DefaultPrinterName()
''rptprint.PrintToPrinter(1, False, 0, 0)
TextBox1.Text = DefaultPrinterName()
rptprint.Close()
rptprint.Dispose()
ocn.Close()
ocn.Dispose()
ods.Dispose()
oda.Dispose()
End Sub
Public Shared Function DefaultPrinterName() As String
Dim oPS As New System.Drawing.Printing.PrinterSettings
Try
DefaultPrinterName = oPS.PrinterName
Catch ex As System.Exception
DefaultPrinterName = ""
Finally
oPS = Nothing
End Try
End Function
But i am getting error "Object reference not set to an instance of an object." at line CrystalReportViewer1.ReportSource = rptprint. And one more thing it is not returning me the correct default printer name as i have shown in textbox1 control.
Kindly help me to get the direct print using crystal report on clicking of a button on client's line matrix / dot matrix printer. I have set "Generic / Text Only" as their default printers.
Regards
Girish Sharma
|
|
|
|
|
|wrote
|i am getting error "Object reference not set to an instance of an object."
This error always raise when creating instance, so confirm that, but your code looks like right one. Before checking these things make sure if the Dataset ods is not null.
|wrote
it is not returning me the correct default printer name
Because these codes are executing in server so you can't get the client machine printer name. So your server machine's default printer name will be displayed in the textbox1. Confirm that. So you can get DefaultPrinter only on server machine using this code.
|wrote
direct print using crystal report on clicking of a button on client's line matrix / dot matrix printer
use the code which i gave you,
System.Net.IPHostEntry host;
host = System.Net.Dns.GetHostEntry(Context.Request.ServerVariables["REMOTE_HOST"]);
string strSystemName = host.HostName;
string strPrinterName = "Generic / Text Only";
rptPrint.PrintOptions.PrinterName = strSystemName + "\\" + strPrinterName; The above code must be run with out fail. Actually i gave you my running code which is using for my clients. I'm not using Oracle, otherwise i'll test your code & make full solution to you, actually i'm using SQL 2005. try my steps & then let me know your feedback.
|
|
|
|
|
First let me thank you again. Here 3 issues :
1."Object reference not set to an instance of an object."
I am not getting why it is giving me this error...
TextBox1.Text = ods.Tables(0).Rows(0).Item("empno") -- No error
rptprint.SetDataSource(ods) -- No error
'CrystalReportViewer1.ReportSource = rptprint -- Error
I have already placed the crystalreportviewer1 control on the page.
2. Since i am using VB for this page, so i am not able to write the
System.Net.IPHostEntry host; code. So, please check the VB conversion is right ?
Dim host As New System.Net.IPHostEntry
host = System.Net.Dns.GetHostEntry(Context.Request.ServerVariables("REMOTE_HOST"))
Dim strSystemName As String = host.HostName
Dim strPrinterName As String = "Generic / Text Only"
rptprint.PrintOptions.PrinterName = strSystemName + "\\" + strPrinterName
3. As far as backend concern, i do'nt think that oracle or sql server is playing any role in this case. I am just using a table and not able to get the error reason.
Actually, i am having less experience in dotnet (printing issues). If my client side printing issue (line matrix / dot matrix, because we need thousands of page printing, after data processing) solves, then i think i would be able to convert my all current foxpro based applications into dotnet using oracle (because i am an OCP).
Thanks with Kind Regards
Girish Sharma
|
|
|
|
|
The 1st one is object instance related issue & then your VB.NET conversion code is right one. Your code looks like right one but something makes trouble. ok let me do something, you just send me the report page, i'll test & will make it run. It should not take more time here after any more.
Regards,
thatraja
thatraja@yahoo.com
|
|
|
|
|
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ocn As New System.Data.OracleClient.OracleConnection
Dim oda As New System.Data.OracleClient.OracleDataAdapter("select empno,ename from emp", ocn)
Dim ods As New System.Data.DataSet()
ocn.ConnectionString = "Data Source=orcl;User ID=scott;Password=pw;Unicode=True"
oda.Fill(ods)
Dim rptprint As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
rptprint.Load(Server.MapPath("Reports").ToString() + "\\CrystalReport.rpt")
'TextBox1.Text = ods.Tables(0).Rows(0).Item("empno") 'This is no error
rptprint.SetDataSource(ods) 'This is no error
CrystalReportViewer1.ReportSource = rptprint 'This is error of object instantiate.
'CrystalReportViewer1.DataBind()
''rptprint.PrintOptions.PrinterName = DefaultPrinterName()
''rptprint.PrintToPrinter(1, False, 0, 0)
'TextBox1.Text = DefaultPrinterName()
rptprint.Close()
rptprint.Dispose()
ocn.Close()
ocn.Dispose()
ods.Dispose()
oda.Dispose()
'Dim host As New System.Net.IPHostEntry
'host = System.Net.Dns.GetHostEntry(Context.Request.ServerVariables("REMOTE_HOST"))
'Dim strSystemName As String = host.HostName
'Dim strPrinterName As String = "Generic / Text Only"
'rptprint.PrintOptions.PrinterName = strSystemName + "\\" + strPrinterName
End Sub
Public Shared Function DefaultPrinterName() As String
Dim oPS As New System.Drawing.Printing.PrinterSettings
Try
DefaultPrinterName = oPS.PrinterName
Catch ex As System.Exception
DefaultPrinterName = ""
Finally
oPS = Nothing
End Try
End Function
End Class
This is what i have in default.aspx.vb file. I have :
1.one crystalreportviewer control
2.one button control
3.one textbox control
I have not yet used your code, because this object instance error is frustraing me.
Regards
Girish Sharma
|
|
|
|
|
Hi, i have checked code, the issue is you are closing & disposing the Report Document object in Button1_Click event which was created there. For that you should create the Report Document object in class & then close & dispose in Page_Unload event.
use the code
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
PrintMode="ActiveX" EnableDatabaseLogonPrompt="false" />
<asp:Button ID="Button1" runat="server" Text="Button" />
Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Web
Partial Public Class _Default
Inherits System.Web.UI.Page
Dim rptprint As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
rptprint.Close()
rptprint.Dispose()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ocn As New System.Data.SqlClient.SqlConnection
Dim oda As New System.Data.SqlClient.SqlDataAdapter("select * from Employees", ocn)
Dim ods As New System.Data.DataSet()
ocn.ConnectionString = "Data Source=RAJA;User ID=sa;Password=123;Initial Catalog=Northwind"
oda.Fill(ods)
rptprint.Load("C:\CrystalReport1.rpt")
rptprint.SetDataSource(ods)
Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
crConnectionInfo.ServerName = "RAJA"
crConnectionInfo.DatabaseName = "Northwind"
crConnectionInfo.UserID = "sa"
crConnectionInfo.Password = "123"
CrTables = rptprint.Database.Tables
For Each CrTable As CrystalDecisions.CrystalReports.Engine.Table In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
CrystalReportViewer1.ReportSource = rptprint
CrystalReportViewer1.DataBind()
ocn.Close()
ocn.Dispose()
ods.Dispose()
oda.Dispose()
End Sub
End Class Here i want to inform you another thing, you can see the property EnableDatabaseLogonPrompt="false" in the designer. This is used for skip the Logon prompt in run time. And then i put the code for assigning the Database logon in codebehind('For DB Login '/For DB Login block) for run time.
Hope you can solve the issues using this code. let me know your feedback.
Regards,
thatraja
|
|
|
|
|
Thank you for your replies. Yes now object error has been removed; but now i am getting further error :
Dim host As New System.Net.IPHostEntry
host = System.Net.Dns.GetHostEntry(Context.Request.ServerVariables("REMOTE_HOST"))
Dim strSystemName As String = host.HostName
Dim strPrinterName As String = "Generic / Text Only"
TextBox1.Text = strSystemName 'Here i am getting 127.0.0.1 not \\mymachine name as you said i.e. \\RAJA In my case it should be \\GIRISH (as this machine where i am using) or on another client machine it should be that client machine's name.
rptprint.PrintOptions.PrinterName = strSystemName + "\\" + strPrinterName
rptprint.PrintToPrinter(1, False, 0, 0)
So, i am getting error : (A new error windows pop up)
COMException was unhandled by user code
Invalid printer specified.
Troubleshooting tips:
Check the ErrorCode property of the exception to determine the HRESULT returned by the COM object.
Get general help for this exception.
Regards
Girish Sharma
|
|
|
|
|
I'm sorry i'm not well since last week with heavy fever that's i can't able to reply quickly. As per my coding, you will be get IP address instead of System name, i mentioned "\\RAJA" for just easy understand. Please mention which line error occurs? ok.
|
|
|
|
|
i dont want to hard code the printer name.
if i do so then it will print the report to same printer every time.
in my office there are 20 comp and each comp has printer connected to it.
i want to print to a printer which is connected to particular client.
thanks,
|
|
|
|