|
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = commonfunctions.fillCategory(1);
}
public static DataTable fillCategory(int catID)
{
DataTable dt = new DataTable();
dt.Columns.Add("CATEGORY_ID", typeof(int));
dt.Columns.Add("CATEGORY_NAME", typeof(string));
dt.Columns.Add("LEVEL", typeof(int));
dt.Columns.Add("PARENT_CATEGORY", typeof(int));
dt = commonfunctions.fillCat(catID, dt, 0);
return dt;
}
public static DataTable fillCat(int catID, DataTable dt, int i)
{
DataTable currdt = new DataTable();
DataTable cdt = new DataTable();
DataTable ccdt = new DataTable();
string query;
query = "SELECT CATEGORY_ID, CATEGORY_NAME, PARENT_CAT_ID FROM CATEGORY_MASTER WHERE CATEGORY_ID = " + catID;
currdt = SqlHelper.ExecuteDatatable(SqlHelper.ConnectionString, CommandType.Text, query);
string name = currdt.Rows[0][1].ToString();
for (int cnt = 0; cnt < i; cnt++)
{
name = "-" + name;
}
dt.Rows.Add(currdt.Rows[0][0], name, i, currdt.Rows[0][2]);
query = "SELECT CATEGORY_ID, CATEGORY_NAME FROM CATEGORY_MASTER WHERE PARENT_CAT_ID = " + catID ;
cdt = SqlHelper.ExecuteDatatable(SqlHelper.ConnectionString, CommandType.Text, query);
foreach (DataRow drc in cdt.Rows)
{
query = "SELECT COUNT(*) FROM CATEGORY_MASTER WHERE PARENT_CAT_ID = " + catID ;
ccdt = SqlHelper.ExecuteDatatable(SqlHelper.ConnectionString, CommandType.Text, query);
if (Convert.ToInt32(ccdt.Rows[0][0].ToString()) > 0)
{
i++;
dt = fillCat(Convert.ToInt32(drc[0].ToString()), dt, i);
i--;
}
else
{
name = drc[1].ToString();
i--;
for (int cnt = 0; cnt < i; cnt++)
{
name = "-" + name;
}
dt.Rows.Add(drc[0], name, i, catID);
}
}
i--;
return dt;
}
---------------------------------------
Here I have just one table.
Category_Master
And Column are :
Category_id
Category_Name
Parent_Category_ID
Join condion is self join.
You can change query and join condtion as per your data.
Regards,
Mayank Parmar
Senior Software Engineer
Amba Tech
Gandhinagar, India
|
|
|
|
|
All the state name values are "select". So the code may be checking if the value is not "select" accept the value. Please try it out with this logic
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
hi guys i am currently using asp.net2 c# to make a website
however i realise i needed some ajax controls so i installed the nessary files
and added the controls( script manager and calender extension)
altohuhg the page run but when the button is click and the date selector is not displayed anyone know y?
|
|
|
|
|
Hi All,
I need to Redirect the page using JavaScript.Is it Possible.If Please Help me.
Thanks and Regards
Narendra
|
|
|
|
|
You can use javascript:window.location.href='testpage.aspx' to redirect through javascript.
Best Regards,
Apurva Kaushal
|
|
|
|
|
|
hi i am trying to use the calendarextension from ajax but
i seem to have a problem it keep saying it need a tag called asp:scriptmanager
however when i try to add it in the page dont regconize it
<asp:ScriptManager runat="Server" EnableScriptGlobalization="true" EnableScriptLocalization="true" / >
|
|
|
|
|
Make sure that the scriptmanager is the first thing (ajax at least) on your page - it must be found before the calandarextension tag...
|
|
|
|
|
yes i done that i seems that the page dosnt regonize asp:scriptmanager do i need to define anything??
|
|
|
|
|
i was testing wit ajax and all i did was create a new c# website fellowed by putting the calender extension control, a textbox and a imagebutton.
setting the calender extension property to link to the textbox and imagebutton
and play.
then it showed an error regarding the script manager
|
|
|
|
|
I created a new ASP.Net website by Visual Studio 2005.
Used language : C#
Database: no use
Then uploaded by menu "Public website" is get error:
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error:
Line 24: ASP.NET to identify an incoming user.
Line 25: -->
Line 26: <authentication mode="None">
Line 27:
Line 28:
|
|
|
|
|
Problem in assigning values to ItemArray...
I am assigning a new value (100) to the existing cell...
But the original value remains unaltered...
Here is the code:
ds.Tables[0].Rows[0].BeginEdit();
ds.Tables[0].Rows[0].ItemArray[0] = 100; ds.Tables[0].Rows[0].EndEdit();
Please help me.
Thank You.
Arun Kumar.A
|
|
|
|
|
Hi,
Try this.
ds.Tables[0].Rows[0].BeginEdit();
ds.Tables[0].Rows[0][0] = 100;
ds.Tables[0].Rows[0].EndEdit();
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Hi,
Thank U for Ur reply.
I will try this out.
Regards,
Arun Kumar.A
|
|
|
|
|
Some people don't know how to encrypt and later decrypt connectionStrings section of your web.config file. I've included a batch file that I use for this all the time. Hope this helps.
-START CRYPT.CMD-
@ECHO OFF
REM NOTE: THIS ASSUMES YOU HAVE INSTALLED VISUAL STUDIO 2005
REM IN THE DEFAULT LOCATION. CHANGE THE TOOL= TO REFLECT
REM YOUR LOCATION IF THIS DOES NOT WORK
set TOOL=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\
IF "%1"=="" GOTO SYNTAX
IF "%1"=="/e" GOTO ENCRYPT
IF "%1"=="/E" GOTO ENCRYPT
IF "%1"=="/d" GOTO DECRYPT
IF "%1"=="/D" GOTO DECRYPT
GOTO SYNTAX
:ENCRYPT
ECHO Encrypting Connection Strings in %2
"%TOOL%aspnet_regiis.exe" -pe "connectionStrings" -app "%2" >NUL
GOTO END
:DECRYPT
ECHO Decrypting Connection Strings in %2
"%TOOL%aspnet_regiis.exe" -pd "connectionStrings" -app "%2" >NUL
GOTO END
:SYNTAX
ECHO INVALID SYNTAX
ECHO CRYPT.CMD
ECHO -------------------------------------------------
ECHO PURPOSE: ENCRYPTS/DECRYPTS the connectionStrings
ECHO section of the Web.Config File for the supplied
ECHO website.
ECHO -------------------------------------------------
ECHO Usage:
ECHO.
ECHO ENCRYPTING THE CONNECTION STRING
ECHO CRYPT /e /WebsiteName
ECHO.
ECHO DECRYPTING THE CONNECTION STRING
ECHO CRYPT /d /WebSiteName
GOTO ENDCLEAN
:END
ECHO Completed..
GOTO ENDCLEAN
:ENDCLEAN
SET TOOL=
-END CRYPT.CMD-
~ CodeDoctor ~
|
|
|
|
|
Hi,
I have a question. I have a gridview in my aspx page. I grabed the data from table. But I want that when I see the aspx page initialy the gridview should be sorted by a column name FirstName in asscending order by default. How can I do that.
Thanks
|
|
|
|
|
In your query that is the data in the table if it is sql you can do
order by FirstName asc
You can also do sorting if you are binding to the datatable directly. Switch to using a DataView and set the sort Property on the dataview.
Something like
DataView dv = yourdataTable.DefaultView;
dv.Sort = "FirstName";
gridview.DataSource = dv;
gridview.DataBind;
Hope that helps.
Ben
|
|
|
|
|
IEI
====
proj_no cst_Amt cst_date cst_typ
Query requirement:
=================
select sum of cst_Amt , month from IEI where cst_typ = 'type1' and proj_no in (select proj_no from IEI where cst_typ = 'type2' and cst_date between '01/01/2006' and '06/01/2006')
===========================================================
select sum(cst_Amt), to_char(cst_date,'MM/01/yyyy') from IEI
where
cst_typ = 'type1' and
proj_no in
(select proj_no
from
IEI where cst_typ = 'type2' and
cst_date between '01/01/2006' and '06/01/2006')
And cst_date between '01/01/2006' and '06/01/2006' group by to_char(cst_date,'MM')
==================
expected output
===============
sum Date
=== ====
212 01/01/2006
434 02/01/2006
434 03/01/2006
434 04/01/2006
434 05/01/2006
434 06/01/2006
|
|
|
|
|
Another idiotic post, well done.
|
|
|
|
|
hi,
I have a web page and it has three textboxes. It has already some text. When I edit the text boxes and click on Edit button the button supposed to epdate the data in the database. But when I debug it the value of textboxes gives me the previous value not the edited value may be in postback it lost it's new value. I set enableviewstate property to True but even then it doesn't work.
Thanks in advance.
hahii
|
|
|
|
|
If you are setting the textbox text in the form load event you need to make sure you have a check on the IsPostBack property. The page load event happens before your edit event, so the data gets set back to its original value in the page load. So you need some code like this:
If (!IsPostBack)
{
textBox.Text = "somevalue";
}
or
If Not IsPostBack Then
textBox.Text = "somevalue
End If
Hope that helps.
Ben
|
|
|
|
|
I have the following code but when I build this it gives me errors that username, userpass, userfname does not exist in current context.
I don't know where is the problem and how can I fix this.
SqlConnection objConn = new SqlConnection("Data Source=sql1300.mssqlservers.com;Initial Catalog=twcsan;Persist Security Info=True;User ID=twcsan;Password=mln0531");
SqlCommand objCmd = new SqlCommand("UPDATE tbUsers SET MyName = @username, " +
"MyPass = @userPass, " +
"UserFName = @userfname, " +
"WHERE UserId = 10", objConn);
objConn.Open();
objCmd.Parameters.AddWithValue(@username1, TextBox1.Text);
objCmd.Parameters.AddWithValue(@userPass, this.TextBox2.Text);
objCmd.Parameters.AddWithValue(@userfname, this.TextBox3.Text);
objCmd.ExecuteNonQuery();
objConn.Close();
Thanks in advance
hahii
|
|
|
|
|
Please try to write a relevant subject. "urgent please help" says nothing about your specific question, and does nothing to distinguish it from all the other questions.
You have forgotten the quotes around the strings.
objCmd.Parameters.AddWithValue("@username1", TextBox1.Text);
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi all,
I have a gridview that has an edit template with a textbox and a dropdown list in it.
At runtime the textbox and dropdown are invisible on the gridview (because they only show in edit view).
When I click "Edit", the textbox and dropdown appear.
I want to be able to reference the dropdown list but when I try to do so, I get the "Object reference not set to an instance of an object." error.
Here is my code:
protected void grdTrak_RowDataBound1(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((DropDownList)e.Row.FindControl("dlStatus")).Attr ibutes.Add("onSelectedIndexChanged", "enableother(this)");
}
}
Does any one know what the problem could be?
Thank you in advance!
Dave
|
|
|
|
|
The row data bound happens for every row in the gridview. Only one row is set in edit mode, so you can not assume you will find the dropdown in each of the rows as they get data bound.
Hope that helps.
Ben
|
|
|
|