# re: DataGrid Paging Events not firing 7/25/2005 3:10 PM Moojjoo
Well everyone... Thank you. I read everybody's response and everyone helped out. My problem was with the ItemCommand Event not firing..
Solutions... Use a link instead of a button worked, but since I am developing for a client I must make everything look the same and use a button. Yes I did copy the code from another Grid that was working and have been scratching my head until I found this site "Thank you GOD".
Solution to fix all...
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack )
{
DataGrid.DataBind();
}
}
What a waste of developer time... ARGH I am dying on my time left on my project...
On to solving streaming an image loaded from Active Directory to a object in memory to presenting it to the end user inside a datalist...
.NET got to love it. 2 more years I should be at the professional level and quote my price for hourly wages... LOL....
This blog is about my history as a software engineer utilizing technologies C#, Java, React, JavaScript, .NET Core, SQL Server , Oracle, GIT, GitHub, Jira, Azure, AWS and HTML5. “I have not failed. I've just found 10,000 ways that won't work.” Thomas A. Edison. Please click on all my ADVERTISING links to help support this blog. Thank you.
Monday, July 25, 2005
Wednesday, July 20, 2005
ADO.NET Accessing Data in a DataSet > DataTable > DataRow
Good Stuff if you return one row from the database.
string strSQL_Table = "Update_Employee";
// Populate Text Boxes with data
txtEmpLanID.Text = ds.Tables[strSQL_Table].Rows[0].ItemArray[0].ToString();
txtEmpFirstName.Text = ds.Tables[strSQL_Table].Rows[0].ItemArray[1].ToString();
txtEmpLastName.Text = ds.Tables[strSQL_Table].Rows[0].ItemArray[2].ToString();
txtEmpNumber.Text = ds.Tables[strSQL_Table].Rows[0].ItemArray[3].ToString();
txtEmpPhone.Text = ds.Tables[strSQL_Table].Rows[0].ItemArray[4].ToString();
string param = ds.Tables[strSQL_Table].Rows[0].ItemArray[5].ToString();
Department_dropdown1.Set_dept_value(param);
this.DataBind();
string strSQL_Table = "Update_Employee";
// Populate Text Boxes with data
txtEmpLanID.Text = ds.Tables[strSQL_Table].Rows[0].ItemArray[0].ToString();
txtEmpFirstName.Text = ds.Tables[strSQL_Table].Rows[0].ItemArray[1].ToString();
txtEmpLastName.Text = ds.Tables[strSQL_Table].Rows[0].ItemArray[2].ToString();
txtEmpNumber.Text = ds.Tables[strSQL_Table].Rows[0].ItemArray[3].ToString();
txtEmpPhone.Text = ds.Tables[strSQL_Table].Rows[0].ItemArray[4].ToString();
string param = ds.Tables[strSQL_Table].Rows[0].ItemArray[5].ToString();
Department_dropdown1.Set_dept_value(param);
this.DataBind();
Tuesday, July 12, 2005
SQL Server Query for all values within a month
I have been working on a project at work and I discovered the following works for retrieving dates from SQL Server:
SELECT * FROM view_Employees_Awards WHERE stringDate BETWEEN '2005-06-01' AND
'2005-07-01' ORDER BY Awarded_Date DESC
The following brings back every date from the beginning of 2005-06-01 00:00:00
To
2005-06-01 23:59:59
SELECT * FROM view_Employees_Awards WHERE stringDate BETWEEN '2005-06-01' AND
'2005-07-01' ORDER BY Awarded_Date DESC
The following brings back every date from the beginning of 2005-06-01 00:00:00
To
2005-06-01 23:59:59
Monday, July 11, 2005
Moojjoo Blog
Moojjoo Blog
Learning more about C# logic everyday. I needed a dropdown that would display dates in a reverse order so how do you do this.
for (int i = DateTime.Now.Year; i >= 2000; i--)
Simple thanks to the MVP at the forums in MSDN
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
"Moojjoo" wrote:
I am building a dropdown select box for year and want to render the dropdown
in reverse order. Using VB I could use step, but I am unsure how to do this
in C#
Any help would be great.
if (!this.IsPostBack)
{
for (int i = 2000; i <= DateTime.Now.Year; i++)
{
int intSubtractTerm = 0;
ListItem newListItem = new ListItem();
intYear = DateTime.Now.Year;
intSubtractTerm = intYear - i;
intYear = intYear - intSubtractTerm;
newListItem.Value = intYear.ToString();
newListItem.Text = intYear.ToString();
DropDownListYear.Items.Add(newListItem);
}
}
Learning more about C# logic everyday. I needed a dropdown that would display dates in a reverse order so how do you do this.
for (int i = DateTime.Now.Year; i >= 2000; i--)
Simple thanks to the MVP at the forums in MSDN
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
"Moojjoo" wrote:
I am building a dropdown select box for year and want to render the dropdown
in reverse order. Using VB I could use step, but I am unsure how to do this
in C#
Any help would be great.
if (!this.IsPostBack)
{
for (int i = 2000; i <= DateTime.Now.Year; i++)
{
int intSubtractTerm = 0;
ListItem newListItem = new ListItem();
intYear = DateTime.Now.Year;
intSubtractTerm = intYear - i;
intYear = intYear - intSubtractTerm;
newListItem.Value = intYear.ToString();
newListItem.Text = intYear.ToString();
DropDownListYear.Items.Add(newListItem);
}
}
Friday, July 08, 2005
Moojjoo Blog - Using User Controls in Datagrid
And the anwser is:
In the code behind:
str_emp_dept = Convert.ToString(((Department_dropdown)e.Item.FindControl("Department_dropdown2")).Selected_dept_value());
WHOOOOOOHOOOOOOO!!!!!!!!!!!!!!
THE QUESTION IS BELOW... WHEN I GET THE ANSWER I WILL POST IT.
I created an user control (.ascx file) with a DropDownList (DDL) with the
following code behide:
public string Selected_dept_value()
{
string dept_value = dept_dropdown.SelectedValue;
return dept_value;
}
All the values were added via the visual interface.
I have droped this on my .aspx page and everything works fine. When making
additions to my datagrid.
<uc1:department_dropdown id="Department_dropdown1" runat="server"></uc1:department_dropdown>
The problem is when I am editing my datagrid.
Where I have:
<asp:templatecolumn headertext="Department">
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, "Emp_Department") %>
</itemtemplate>
<edititemtemplate>
<uc1:department_dropdown id="Department_dropdown2" runat="server">
</uc1:department_dropdown>
</edititemtemplate>
The DDL displays fine, but I cannot get the values when clicking update:
Here is the error and code behind that it is failing on:
Error: Object reference not set to an instance of an object <-- However I
have the following:
protected Department_dropdown Department_dropdown2;
Code:
str_emp_dept =
((DropDownList)e.Item.FindControl(Department_dropdown2.Selected_dept_value())).SelectedValue;
In the code behind:
str_emp_dept = Convert.ToString(((Department_dropdown)e.Item.FindControl("Department_dropdown2")).Selected_dept_value());
WHOOOOOOHOOOOOOO!!!!!!!!!!!!!!
THE QUESTION IS BELOW... WHEN I GET THE ANSWER I WILL POST IT.
I created an user control (.ascx file) with a DropDownList (DDL) with the
following code behide:
public string Selected_dept_value()
{
string dept_value = dept_dropdown.SelectedValue;
return dept_value;
}
All the values were added via the visual interface.
I have droped this on my .aspx page and everything works fine. When making
additions to my datagrid.
<uc1:department_dropdown id="Department_dropdown1" runat="server"></uc1:department_dropdown>
The problem is when I am editing my datagrid.
Where I have:
<asp:templatecolumn headertext="Department">
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, "Emp_Department") %>
</itemtemplate>
<edititemtemplate>
<uc1:department_dropdown id="Department_dropdown2" runat="server">
</uc1:department_dropdown>
</edititemtemplate>
The DDL displays fine, but I cannot get the values when clicking update:
Here is the error and code behind that it is failing on:
Error: Object reference not set to an instance of an object <-- However I
have the following:
protected Department_dropdown Department_dropdown2;
Code:
str_emp_dept =
((DropDownList)e.Item.FindControl(Department_dropdown2.Selected_dept_value())).SelectedValue;
Wednesday, April 13, 2005
RECORD COUNT ADO.NET, C#
Moojjoo Blog
THE FOLLOWING CODE IS FOR COUNTING RECORDS IN A DATABASE USING ADO.NET, C#
//string countSQL = "SELECT COUNT(userID) FROM CamelHeadCount WHERE userID =" + GetUserName();
string countSQL = "SELECT COUNT(userID) FROM CamelHeadCount WHERE userID = 'DANNELR'";
SqlConnection Conn = new SqlConnection(strConn);
SqlCommand myCommand = new SqlCommand(countSQL, Conn);
Conn.Open();
Int32 recordCount = (Int32) myCommand.ExecuteScalar();
if (recordCount > 0)
{
Response.Write("Our records indicate that you have already confirmed");
Response.End();
}
Conn.Close();
THE FOLLOWING CODE IS FOR COUNTING RECORDS IN A DATABASE USING ADO.NET, C#
//string countSQL = "SELECT COUNT(userID) FROM CamelHeadCount WHERE userID =" + GetUserName();
string countSQL = "SELECT COUNT(userID) FROM CamelHeadCount WHERE userID = 'DANNELR'";
SqlConnection Conn = new SqlConnection(strConn);
SqlCommand myCommand = new SqlCommand(countSQL, Conn);
Conn.Open();
Int32 recordCount = (Int32) myCommand.ExecuteScalar();
if (recordCount > 0)
{
Response.Write("Our records indicate that you have already confirmed");
Response.End();
}
Conn.Close();
Saturday, April 02, 2005
ADO.NET Error Occurred: Operation must use an updateable query
Error Occurred: Operation must use an updateable query.I keep receiving the following error: 'sliderbutton.gif' Received...Content-Type: image/gifContent-Length: 138File Name: Y:\documents\Another6\sliderbutton.gifError Occurred: Operation must use an updateable query.Does anyone know what is the problem? Thank you for your time.Victorponce22@yahoo.com
Reply
Posted by Faisal Khan on November-22-2003
Give READ/WRITE permissionsYou'll have to give READ/WRITE permissions for the user IUSR_MACHINENAME to the folder where you are trying to upload (i.e. write) files.------------------Faisal Khan.Stardeveloper.com
In Reply To Reply
Posted by spectreman on January-14-2004
This fix worked for me.I found this on another board. I'm using XP pro, which apparently hides true folder permissions control by default... after you turn of this stupid feature, you can then give 'write' permission to All Users for the .mdb.Here's how:okay Chris_Gilbert and all others who have the same Access DB problem. I provided the solution in pervious post for W2K. I was then having same problem on XP Pro and I have solved the problem after searching a LOT. Okay, here is the solution: - open the Explorer - click on Tools and then Folder Options - goto View tab - scroll down all the way and the last item (i think) will say "Use simple file sharing" - uncheck it if it is checked - now, goto appropriate .mdb file and right click - click on properties - goto Security tab - select Everyone from User - check "Write" checkbox under Everyone as a user VOILA.......You have done it!!!!!! This should work now. It worked for me and now I can run SQL command from frontend to update my Access database.
In Reply To Reply
Posted by jrgonline on November-11-2004
This didn't workthis fix didn't work for me.... i'm still getting the same error. i used the files that were available in the ZIP at the end of this article... do I need to change something within any of those files?------------------"America cannot lead the world's future if our elected officials keep us chained to tradition."
In Reply To Reply
Posted by zedfalco on March-29-2005
thanks a lot spectremanthat`s has worked for me. After I was looking for a solution the all day!Thank
Reply
Posted by Faisal Khan on November-22-2003
Give READ/WRITE permissionsYou'll have to give READ/WRITE permissions for the user IUSR_MACHINENAME to the folder where you are trying to upload (i.e. write) files.------------------Faisal Khan.Stardeveloper.com
In Reply To Reply
Posted by spectreman on January-14-2004
This fix worked for me.I found this on another board. I'm using XP pro, which apparently hides true folder permissions control by default... after you turn of this stupid feature, you can then give 'write' permission to All Users for the .mdb.Here's how:okay Chris_Gilbert and all others who have the same Access DB problem. I provided the solution in pervious post for W2K. I was then having same problem on XP Pro and I have solved the problem after searching a LOT. Okay, here is the solution: - open the Explorer - click on Tools and then Folder Options - goto View tab - scroll down all the way and the last item (i think) will say "Use simple file sharing" - uncheck it if it is checked - now, goto appropriate .mdb file and right click - click on properties - goto Security tab - select Everyone from User - check "Write" checkbox under Everyone as a user VOILA.......You have done it!!!!!! This should work now. It worked for me and now I can run SQL command from frontend to update my Access database.
In Reply To Reply
Posted by jrgonline on November-11-2004
This didn't workthis fix didn't work for me.... i'm still getting the same error. i used the files that were available in the ZIP at the end of this article... do I need to change something within any of those files?------------------"America cannot lead the world's future if our elected officials keep us chained to tradition."
In Reply To Reply
Posted by zedfalco on March-29-2005
thanks a lot spectremanthat`s has worked for me. After I was looking for a solution the all day!Thank
Thursday, March 31, 2005
C# ADO.NET
The first step in any database operation is to create a Connection object and establish the connection by calling its Open() method.
Wednesday, March 30, 2005
C# Clearing dropdownlist.listitems
If you are trying to clear a listitems in asp.net simple type the following:
myList.Items.Clear();
Moojjoo Blog
myList.Items.Clear();
Moojjoo Blog
Saturday, March 05, 2005
Subscribe to:
Posts (Atom)