|
Can anybody tell me how can I copy a whole data column from a data table into an array of integers ?
OR how can I read values of all the rows of a datacolumn (using for loop) and then pass these values to an array (double [] data).
|
|
|
|
|
System.Collections.Generic.List<int> intValues = new List<int>();
foreach (DataRow r in dt.Rows)
{
//FIx to hand nulls if necessary
intValues.Add((int)r["myColumnName"]);
}
return (int[])intValues.ToArray();
I didn't get any requirements for the signature
|
|
|
|
|
Thanks for taking interest in my problem. My solution file successfully builds up at compile time but at run time , I am getting following error. Please help.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 93: {
Line 94: //FIx to hand nulls if necessary
Line 95: data.Add((double)r["A"]);
Line 96: }
Line 97: // return (double[])intValues.ToArray();
Source File: C:\Users\Ashutosh\Documents\Visual Studio 2008\Projects\testing_buttonClickEvent\testing_buttonClickEvent\Default.aspx.cs Line: 95
Stack Trace:
[InvalidCastException: Specified cast is not valid.]
testing_buttonClickEvent._Default.Button1_Click(Object sender, EventArgs e) in C:\Users\Ashutosh\Documents\Visual Studio 2008\Projects\testing_buttonClickEvent\testing_buttonClickEvent\Default.aspx.cs:95
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +107
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3436
|
|
|
|
|
put a break point on there and check to see what type r["A"] is. perhaps it is dbnull or some other value that is not a double. should be an easy fix.
I didn't get any requirements for the signature
|
|
|
|
|
Hey there, I've got a string of xml that is saved in a database as an image. I'm having troubles with the conversion of the binary data to a string so that I can use it. The closest I seem to have gotten is to have a string of 0s returned.
byte[] bytXML = (byte[])(oDataView[i]["XMLData"]);
System.IO.MemoryStream oReader = new System.IO.MemoryStream();
string sXML = "";
for (int iCount = 0; iCount < bytXML.Length; iCount++) {
sXML = sXML + oReader.Read(bytXML,iCount,1).ToString();
}
oReader.Close();
divXML.InnerHtml = sXML;
Any help would be much appreciated.
|
|
|
|
|
Why is it not coming from the DB as a string ?
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Found that the data was actually compressed and that I had been returning the data correctly the entire time.
|
|
|
|
|
hello
Reading a sample from MSDN:
<br />
<%@ Page Language="C#" uiculture="auto" %><br />
<%@ Import Namespace="System.Threading" %><br />
<%@ Import Namespace="System.Globalization" %><br />
<script runat="server"><br />
protected override void InitializeCulture()<br />
{<br />
if (Request.Form["ListBox1"] != null)<br />
{<br />
String selectedLanguage = Request.Form["ListBox1"];<br />
UICulture = selectedLanguage ;<br />
Culture = selectedLanguage ;<br />
<br />
Thread.CurrentThread.CurrentCulture = <br />
CultureInfo.CreateSpecificCulture(selectedLanguage);<br />
Thread.CurrentThread.CurrentUICulture = new <br />
CultureInfo(selectedLanguage);<br />
}<br />
base.InitializeCulture();<br />
}<br />
</script><br />
In this example, line "Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage)" set the culture for "CurrentThread" - but if there're say thirty users, is this visible to all of them?
Thanks
http://msdn.microsoft.com/en-us/library/bz9tc508.aspx[^]
dev
|
|
|
|
|
I get error bellow when loading report any help please?
The database DLL 'crdb_oracle.dll' could not be loaded. Error in File
|
|
|
|
|
What about this[^]?
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Simple QQ)
in codebehind its not taking the gridview id..why?
i am getting errors.. it does not exists in the contex
can anyone answer..
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="grd1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" ondatabinding="grd1_DataBinding"
ondatabound="grd1_DataBound" onrowcreated="grd1_RowCreated"
onrowdatabound="grd1_RowDataBound" OnSelectedIndexChanged="grd1_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="sno" HeaderText="sno" SortExpression="sno" />
<asp:BoundField DataField="description" HeaderText="description"
SortExpression="description" />
<asp:BoundField DataField="Year1" HeaderText="Year1" SortExpression="Year1" />
<asp:BoundField DataField="Year2" HeaderText="Year2" SortExpression="Year2" />
<asp:BoundField DataField="Year3" HeaderText="Year3" SortExpression="Year3" />
<asp:BoundField DataField="Year4" HeaderText="Year4" SortExpression="Year4" />
</Columns>
</asp:GridView>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
CommonDBConnectionString="<%$ CommonDBConnectionString:CommonDBConnectionString %>"
SelectCommand="SELECT * FROM [Jurisdiction]"></asp:SqlDataSource>
</form>
</body>
</html>
|
|
|
|
|
You seem to be missing a closing gridview tag.
|
|
|
|
|
|
Is what I am asking possible?
O.
|
|
|
|
|
Hi,
For my asp.net website project i needed to find the ISP of the user who is accessing the website.
Please help.
Thanks in advance
Jophin
jophin
|
|
|
|
|
jophinmichael wrote: i needed to find the ISP of the user
ISP or IP?
If IP then here [^]is the example
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
The only way you can hope to do that, is if you have a database of IP address ranges which tells you which IPs are assigned for a given ISP. Don't expect to get this for free.
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
Hi,
I am using .net membership provider for authentication purpose. I have the following requirement.
If a user first time login to an application and the password hasn’t been changed (assume this user created by admin and the password is provided to user by admin) i should not validate the user until or unless he change the password provided by admin. I dont know how to accompolish this task. I meant how do i come to know tat this is the first time the user login to the application. Is there any property is available in the .net membership provider or any other way.
Help would be greatly appreciated
With Regards,
Anand
|
|
|
|
|
Hey am using repeater control to populate the data using datatable..
in my table the row cells some has values some has 0(zero) value.... i have to make the value of cell as hyperlink/button ..how can i do tht..my table looks like as i given blow..
Could any one suggest me...
Jurdiction 2007 2008 2009
NC 0 6 3
VA 4 0 5
NY 0 7 0
|
|
|
|
|
mahichandu wrote: in my table the row cells some has values some has 0(zero) value.... i have to make the value of cell as hyperlink/button
Well, to treat partiular data case by case, you can not use databind method.
Instead, you should use a loop and add the items. Check the data and if it matches your condition(as you say 0 here), make the that a Hyperlink Column.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
hmmmm.. could ou just send me sample code which way i have to add..which event i have to add this looping statements..in Pageload only na...
i don't have much knowledge on C# technolgies..
I am thinking i have to to take new datatable..adding the item & check the data..hear how to prceed..
Could u do this help
|
|
|
|
|
|
There are may ways of doing the same.
I am presenting one way of doing it
I am taking a datatable as my datasource(and ofcourse you have also taken that )
So here it goes
Step 1: Create datatable
DataTable dtSource = new DataTable();
#region Data Table Creation
dtSource.Columns.Add("Jurdiction");
dtSource.Columns.Add("2007");
dtSource.Columns.Add("2008");
dtSource.Columns.Add("2009");
#endregion
#region Add Rows
dtSource.Rows.Add("NC", "0", "6", "3");
dtSource.Rows.Add("VA", "4", "0", "5");
dtSource.Rows.Add("NY", "0", "7", "0");
#endregion
Step 2:Create a repeater control in your .aspx page
<asp:Repeater ID="myRepeater" runat="server">
</asp:Repeater>
Step 3:Bind the datatable to the repeater control which is there in the .aspx page
myRepeater.DataSource = dtSource;
myRepeater.DataBind();
Step 4:Create a user control say Headercontrol.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="HeaderControl.ascx.cs" Inherits="HeaderControl" %>
<table width="40%">
<tr>
<td style="width:10%">
<asp:Label ID="lblHeaderCol1" runat="server" Text="Jurdiction"></asp:Label>
</td>
<td style="width:10%">
<asp:Label ID="lblHeaderCol2" runat="server" Text="2007"></asp:Label>
</td>
<td style="width:10%">
<asp:Label ID="lblHeaderCol3" runat="server" Text="2008"></asp:Label>
</td>
<td style="width:10%">
<asp:Label ID="lblHeaderCol4" runat="server" Text="2009"></asp:Label>
</td>
</tr>
</table>
Step 5:Create another user control say ContentControl.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContentControl.ascx.cs" Inherits="ContentControl" %>
<table width="40%">
<tr>
<td style="width:10%">
<asp:Label ID="lblContentColumn1" runat="server"></asp:Label>
</td>
<td style="width:10%">
<asp:LinkButton ID="lnkContentColumn2" runat="server"></asp:LinkButton>
</td>
<td style="width:10%">
<asp:LinkButton ID="lnkContentColumn3" runat="server"></asp:LinkButton>
</td>
<td style="width:10%">
<asp:LinkButton ID="lnkContentColumn4" runat="server"></asp:LinkButton>
</td>
</tr>
</table>
Step 6:Expose the following properties in the ContentControl.ascx.cs
#region Properties
public string Jurdiction { get; set; }
public string Content2007 { get; set; }
public string Content2008 { get; set; }
public string Content2009 { get; set; }
#endregion
Step 7: In the Page_Load event of ContentControl.ascx.cs, add the following
protected void Page_Load(object sender, EventArgs e)
{
lblContentColumn1.Text = Jurdiction;
lnkContentColumn2.Text = Content2007;
lnkContentColumn3.Text = Content2008;
lnkContentColumn4.Text = Content2009;
}
Step 8: Call the Header.ascx user control from inside the <HeaderTemplate> of the repeater and the ContentControl.ascx from inside the <ItemTemplate> of the repeater.
It is given below
<asp:Repeater ID="myRepeater" runat="server">
<HeaderTemplate>
<uc2:HeaderControl ID="HeaderControl1" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<uc1:WebUserControl ID="WebUserControl1" runat="server" Jurdiction=<%# DataBinder.Eval(Container.DataItem, "Jurdiction")%> Content2007=<%# DataBinder.Eval(Container.DataItem, "2007")%> Content2008=<%# DataBinder.Eval(Container.DataItem, "2008")%> Content2009=<%# DataBinder.Eval(Container.DataItem, "2009")%> Counter = <%# Container.ItemIndex%> />
</ItemTemplate>
</asp:Repeater>
N.B.~ The various properties that I have exposed from the ContentControl.ascx, are consumed inside the itemtemplate.
So What I am doing?
Basically in the header user control , I have defined the Column names to be printed
and in the ContentUserControl I have attached the cell values to the link buttons.
I am calling the user control from inside the item template ; so each time the user control will be iterated.
N.B.~ This is one of the solutions that came in my mind instantly.
Hope it will help you.
Niladri Biswas
|
|
|
|
|
Hello!
Can someone explain it to me how can I get the DataValue from a listBox. I have one listBox, which is binded with an SqlDataSource, which returns the ID and the Description from a table. I've set the data field to desplay the description and the data field for the value for the list box to the ID. I need when I set the ID from another control to mark the relevant data field in the ListBox and then the other way around. When is some value field chosen from the user in the ListBox I want to get the data field value of the ListBox.
Pleeeease help!
Thanks in advnace!
|
|
|
|
|
Hello All,
I have facing one issue that when i have download any file through file download dialog box before i got message dialog box like
"This page contains both secure and nonsecure items. Do you want to display
the nonsecure items."
can you please tell me how to fixed that issue through code in c#?
That issue only face in IE 6. but in IE 7 it is working fine.
Thanks in Advance.
Anish Patel
|
|
|
|