|
Take Label in Template Column
U can get value By ((Label)e.Item[index].FindControl("lblid")).Text
Best Regard
Pathan
GOD HELP THOSE WHO HELP THEMSELVES
|
|
|
|
|
Hi I tried to use an if statement to determine when myCon is null when no item of ListBox2 is selected like the following.
<br />
Dim i As Integer<br />
Dim myCon As OdbcConnection<br />
Dim cmd as OdbcCommand<br />
myCon = New OdbcConnection("Driver={MySQL ODBC 3.51Driver}; Server=myServer;Database=myDB;User=myUserassword=myPass;Option=3;")<br />
<br />
For i = 0 To ListBox2.Items.Count - 1<br />
If ListBox2.Items(i).Selected Then<br />
<br />
cmd = New OdbcCommand("SELECT * FROM myTable where Professions = '"& ListBox2.Items(i).Text &"' ")<br />
End If<br />
Next<br />
If Not IsNothing(myCon) then <br />
myCon.Open()<br />
<br />
cmd.Connection = myCon<br />
<br />
Dim ds As New DataSet<br />
<br />
Dim ad As New OdbcDataAdapter(cmd)<br />
<br />
ad.Fill(ds)<br />
<br />
Me.ListBox2.DataSource = ds<br />
<br />
Me.ListBox2.DataTextField = "Professions"<br />
<br />
Me.ListBox2.DataBind()<br />
End IF<br />
When viewed in the browser I get the exception "Object reference not set to an instance of an object". I have read that the most common causes of this exception are not declaring the variables before using them, bad scoping, and not using the key word New when instantiating. I thought I have made sure that the afore mentioned causes are not the causes of the error I'm getting but obviously there is something wrong with my code. Please help me identify the cause of the exception, I just can not see what it could be at the moment. Thank you in advance for your help.
|
|
|
|
|
What's wrong with the selectedItem property ?
When you get this error, you need to step through the code and work out what is Nothing. You really have a list box called 'ListBox2' ???
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
This has popped up a few times Christian, links to the MSDN entries on the ListBox class have been provided at least once before, but I don't think the poster has a lot of, (if any), understanding of the responses that have been given thus far, or of what he's doing.
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
There are a couple of things you can do here. The first (and best) case would be to set a breakpoint at the first line of code and step through the function to see where it breaks. If you watch the variables as you step through, you should be able to figure out where the null value is quite quickly.
The second method would be to wrap this up in a Try/Catch block and set a breakpoint in the Catch. The exception that was thrown would contain full information including a stack trace which you can use to identify which line of code is failing.
My choice - go with option 1. Part of becoming a professional programmer is learning how to debug code effectively. As a general note, you should only come to CP if you have a problem after you have stepped through the code. Seriously, debugging the code is a great way to learn how to problem solve.
|
|
|
|
|
I have a gridview that loads about 2-50 records. While the query in SQL Query analyzer takes less than a couple seconds to run it takes forever for the gridview to load the data from an sqldatasource in sqldatareader mode. Has anybody has experienced somtehing like this?
|
|
|
|
|
Well, a grid view is not loading data, you should have code that does this, which won't be much slower, but then it needs to also generate HTML to display it, along with all the doohickeys you have turned on.
A repeater would be faster, but it does nothing, you have to totally style it yourself.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am not sure about the term "loading data" but it takes forever to execute the gridview.databind. I guess it takes forever to create the HTML code.
|
|
|
|
|
I am working on a job posting web site and I am using the index server to be able to search thru individual jobs that get ftp up.
The problem is how do I truncate the data or extract the data out of the characterization.
Here is an example of the contents of my characterization.
15010, CEV Demo Chief Engineer - Space .
Category: Engineering.
Region: CA-Los Angeles/Orange Counties.
City: El Segundo.
State: CA.
Rate: $60.00 - $65.00.
Duration: 6 - 12 Months.
Description: Technical Integrity, CEV, Spacecraft Systems~.
RESPONSIBILIITES:. Responsible to the CEV Demo IPT Leader and Program
I need to bind to a gridview to the first line... that would only be the job number. Then I want the rest for the next column to have the job title. After that, the description is my keywords for my next column and then a combo of State and City in one column and the final column to have the Rate.
I thought I could use substrings and pathindex to get the individual data out, but that didn't work.
thanks
mjc
|
|
|
|
|
Ok, I got it to work. What I did was saved query result into a dataset and then using string functions to get my data out and then create a datatable and added each row with data from the dataset.
Dim accessConnection As OleDbConnection = New OleDbConnection("Provider=MSIDXS")
Dim accessCommand As New OleDbCommand(query, accessConnection)
Dim newjobsDataAdapter As New OleDbDataAdapter(accessCommand)
Dim myDataSet As New DataSet()
Dim newjobsDataTable As New DataTable("newjobs")
newjobsDataAdapter.Fill(myDataSet, "newjobs")
Dim dataTableRowCount As Integer = newjobsDataTable.Rows.Count
Dim myDataTable As DataTable = myDataSet.Tables(0)
Dim tempdata As String
Dim spc1 As Integer
Dim spc2 As Integer
Dim spc3 As Integer
Dim spc4 As Integer
myDataTable.Columns.Add(New DataColumn("ID", GetType(Integer)))
myDataTable.Columns.Add(New DataColumn("JobID", GetType(Integer)))
myDataTable.Columns.Add(New DataColumn("JobTitle", GetType(String)))
myDataTable.Columns.Add(New DataColumn("Keywords", GetType(String)))
myDataTable.Columns.Add(New DataColumn("Location", GetType(String)))
myDataTable.Columns.Add(New DataColumn("Rate", GetType(String)))
For i = 0 To myDataTable.Rows.Count - 1
myDataTable.Rows(i)("ID") = i + 1
tempdata = myDataTable.Rows(i)("characterization")
spc1 = InStr(myDataTable.Rows(i)("characterization"), ",")
spc2 = InStr(myDataTable.Rows(i)("characterization"), ". Category")
myDataTable.Rows(i)("JobID") = Convert.ToInt32(Mid(tempdata, 1, spc1 - 1))
myDataTable.Rows(i)("JobTitle") = LTrim(Mid(tempdata, spc1 + 2, spc2 - 8))
spc1 = InStr(myDataTable.Rows(i)("characterization"), "Description")
spc2 = InStr(spc1, myDataTable.Rows(i)("characterization"), "~.")
myDataTable.Rows(i)("Keywords") = LTrim(Mid(tempdata, spc1 + 13, spc2 - spc1 - 12))
spc1 = InStr(myDataTable.Rows(i)("characterization"), "State")
spc2 = InStr(spc1, myDataTable.Rows(i)("characterization"), ".")
spc3 = InStr(myDataTable.Rows(i)("characterization"), "City")
spc4 = InStr(spc3, myDataTable.Rows(i)("characterization"), ".")
myDataTable.Rows(i)("Location") = LTrim(Mid(tempdata, spc1 + 7, spc2 - spc1 - 7)) + ", " + LTrim(Mid(tempdata, spc3 + 6, spc4 - spc3 - 6))
spc1 = InStr(myDataTable.Rows(i)("characterization"), "Rate")
spc2 = InStr(spc1, myDataTable.Rows(i)("characterization"), ".")
myDataTable.Rows(i)("Rate") = LTrim(Mid(tempdata, spc1 + 6, spc2 - spc1 - 6))
Next
Dim myDataView As DataView = myDataTable.DefaultView
If myDataTable.Rows.Count > 0 Then
GridView1.DataSource = myDataView
GridView1.DataBind()
End If
Hope this helps other people.
|
|
|
|
|
am using visual studio 2005 and I am trying to create a popup calender so
when a user click on a image on the main form, a calender will then popup,
the user will select a date and the date will then be passed back to the main
form and populate a textbox. it works fine. but when i used master page for
all my pages and i put the textbox inside the content , the calender pops up
but when i select the date nothing happens .. the textbox was not populated
with the selected date from the calender and the window was not closed.
Here is my code
Default Page/Parent Window/
function GetDate(CtrlName)
{
ChildWindow = window.open('Calendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' + CtrlName, "PopUpCalendar", "width=270,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no");
}
<asp:textbox id="txtStartDate" runat="server">
Start Date
Code for the Calendar Page/Child Page/
<asp:content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="Server">
function ReturnDate()
{
window.opener.document.forms["<%= strFormName %>"].elements["<%=strCtrlName %>"].value = "<%= strSelectedDate %>";
window.close();
}
function Close()
{
window.close();
}
Public strFormName As String
Public strCtrlName As String
Public strSelectedDate As String
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack Then
myCalendar.SelectedDate = System.DateTime.Now()
End If
strSelectedDate = myCalendar.SelectedDate.ToString("dd/MM/yyyy")
strFormName = Request.QueryString("FormName")
strCtrlName = Request.QueryString("CtrlName")
End Sub
Sub myCalendar_SelectionChanged(sender As Object, e As EventArgs)
strSelectedDate = myCalendar.SelectedDate.ToString("dd/MM/yyyy")
End Sub
</script
<asp:Calendar id="myCalendar" runat="server" OnSelectionChanged="myCalendar_SelectionChanged">
</asp:Calendar>
<input id="btnReturnDate" onclick="Javascript:ReturnDate()" type="button" value="Select" runat="Server" />
<input id="btnCloseWindow" onclick="Javascript:Close()" type="button" value="Close" runat="Server" />
</asp:Content>
I need help
kidus
|
|
|
|
|
Hi,
I am also suffered with that problem. The problem is when you put the controls inside master page:
other container controls that
the runtime engine seems to change the names of the controls and adds
the '$' Character to them. You might want to view the rendered HTML
source sent to the browser.
And change your code according to those control name changes in masterpage.
Hope this helps.
|
|
|
|
|
I add to the name of the controls $ but there is no difference.Make it clear
pls help
kidus
|
|
|
|
|
And I put the controls inside the Asp:Content not Master page.
|
|
|
|
|
Hi,
In master page you can find the content place holder <asp:content ..="">
window.open('popup.aspx?textbox=ctl00_Body_Wizard1_txtBoxElectionDate1' here ctl00_Body_txtBoxElectionDate1 is the my text box name which i got be seeing the view source. use that name here.
And In popup.aspx I used like this:
String strScript = "window.opener.document.forms['aspnetForm']." + control.Value + ".value = '";
strScript += calDate.SelectedDate.ToString("MM/dd/yyyy");
strScript += "';self.close()";
strScript += "</" + "script>";
RegisterClientScriptBlock("anything", strScript);
aspnetForm is the the form name which contain the textbox to put the selected date.
Check your code.
Hope this helps.
|
|
|
|
|
hi
Thank you for your fast response
in the code
String strScript = "window.opener.document.forms['aspnetForm']." + control.Value + ".value = '";
the form name 'aspnetForm'.There is only one form in the master page.No other forms in the other pages.My text box is in the other pages.
Any help
kidus
|
|
|
|
|
you have to modifiy like this
onclick ="javascript:GetDate('ctl00$ContentPlaceHolder1$"Text box name here"')"
|
|
|
|
|
Hi All,
I am looking for very efficient solution for this problem. Here is my problem description - I have serveral database,
from which I have to pull data (All databases differ in physical design implementation), and insert them in standardized
common database. Let me give you an example
Database - 1
Table - 1
Col_1 - int
Col_2 - text
Col_3 - float
Database - 2
Table - 2
Col_1 - int
Col_2 - int
Col_3 - float
Col_4 - text
Col_5 - text
Common database
col_1 (id) - int
col_2 - int
col_3 - float
col_4 - text
So mapping between database - 1 and common database would be
col_1 --> col_2
col_2 --> col_4
col_3 --> col_3
and between database - 2 and commond database would be
col_1 --> col_2
col_2 --> col_2
col_3 --> col_3
col_4 --> col_4
col_5 --> col_4
How can I achive this? One more thing, this mapping can be changed during runtime.
Thanks,
AP
|
|
|
|
|
patelash01 wrote:
How can I achive this?
Just code the mappings you have supplied...
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi
I have been playing around with a password hashing scheme for my application
But i keep getting an error message when it executes the command object
i get the error
Unable to cast object of type 'System.byte[]' to type 'system.inconvertible'
Any suggestions?
Sub CreateAccount(ByVal sender As Object, ByVal e As EventArgs)
Dim literror As New LiteralControl
'1. Create a connection
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=localhost; ;database=ftp1;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
Try
'2. Create a command object for the query
Dim strSQL As String = _
"INSERT INTO Useraccount(Username,Password) " & _
"VALUES(?Username, ?Password)"
Dim objCmd As New MySqlCommand(strSQL, connection)
'3. Create parameters
Dim paramUsername As MySqlParameter
paramUsername = New MySqlParameter("?Username", SqlDbType.VarChar, 25)
paramUsername.Value = txtUsername.Text
objCmd.Parameters.Add(paramUsername)
'Encrypt the password
Dim md5Hasher As New MD5CryptoServiceProvider()
Dim hashedBytes As Byte()
Dim encoder As New UTF8Encoding()
hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(txtPwd.Text))
Dim paramPwd As MySqlParameter
paramPwd = New MySqlParameter("?Password", SqlDbType.Binary, 16)
paramPwd.Value = hashedBytes
objCmd.Parameters.Add(paramPwd)
'Insert the records into the database
connection.Open()
objCmd.ExecuteReader()
connection.Close()
Catch ex As Exception
literror.Text = ex.Message
MsgBox(ex.Message)
End Try
Response.Redirect("userhome.aspx")
End Sub
|
|
|
|
|
There is no cross-posting!
______________________
stuff + cats = awesome
|
|
|
|
|
So, instead of continuing the thread you started in the VB.NET forum, you decided to spam the ASP.NET forum with the same question? Do you really understand how forums work?
So, did you double check the items I brought up in my previous reply in the VB.NET forum, or did you just ignore them entirely?
|
|
|
|
|
I appologise all I will need to get of this hash and salt, apparently hash and pepper can be good?
Yes i did take account to what you said, and i believe SHA2 is a more secure encryption? and i have now ported my code to that.
Although I am still being hit with the same problem, I checked my field types and lengths and still no joy with that either
|
|
|
|
|
Try converting your byte() array to a Base64 string, then save that to the database.
|
|
|
|
|
The title of the post looks like you want to know about seasoning the drugs you obviously used when you decided to cross post. You've angered Leckey now - that's not a good thing.
|
|
|
|
|