|
do you use the if Page.IsPostback Then construction?
If that is false only then you should call your property.
This is due to AJAX
also check your code:
If (sortExpression = e.SortExpression) Then
If gridSortDirection = SortDirection.Ascending Then
gridSortDirection = SortDirection.Descending
Else
gridSortDirection = SortDirection.Ascending
End If
Else
gridSortDirection = WebControls.SortDirection.Ascending
End If
what are the values in a debug of:
sortExpression, gridSortExpression
and what path does it run in the if sections?
|
|
|
|
|
this is my design code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login page.aspx.cs" Inherits="Login_page" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<!-- <summary>
||||| Style Sheet |||||
</summary>
--><link title="standard" href="Styles.css" type="text/css" rel="stylesheet">
</head>
<body>
<!-- ||||| Login Form ||||| -->
<form id="frmlogin" method="post" runat="server">
<table id="mainTable" border="0" style="left: 368px; position: relative; top: 177px">
<tr>
<td>
<table class="t_border" id="loginTable" cellspacing="15" cellpadding="0" style="left: -1px; position: relative; top: 12px">
<tr>
<td style="height: 24px"><b>Login: </b>
</td>
<td style="height: 24px"><asp:textbox id="txtUserName" runat="server" width="160px"></asp:textbox></td>
</tr>
<tr>
<td><b style="position: relative">Password: </b>
</td>
<td><asp:textbox id="txtPassword" runat="server" width="160px" textmode="Password"></asp:textbox></td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="height: 21px; position: relative;">
<asp:Label ID="Label3" runat="server" Font-Size="Large" Style="left: 5px; position: relative;
top: -3px" Text="Selcet Center"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" style="left: 6px; position: relative; top: 1px">
<asp:ListItem>Select Type</asp:ListItem>
<asp:ListItem>Service Center</asp:ListItem>
<asp:ListItem>Call Center</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td style="height: 21px"><asp:Label ID="Label4" runat="server" Font-Size="Large" Text="Select Zone" style="left: 5px; position: relative; top: 0px" Width="97px"></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server" Width="111px" style="left: 5px; position: relative; top: -1px">
<asp:ListItem>Select Zone</asp:ListItem>
<asp:ListItem>West Zone</asp:ListItem>
<asp:ListItem>North Zone</asp:ListItem>
<asp:ListItem>South Zone</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td align="center" colspan="2"><asp:button id="Button1" runat="server" text="Submit" borderstyle="Solid" OnClick="Button1_Click1"></asp:button></td>
</tr>
</table>
</form>
<asp:label id="lblMessage" runat="server" width="288px" font-bold="True" font-italic="True"
font-size="Medium" forecolor="#C00000" style="left: -2px; position: relative; top: 286px"></asp:label>
<asp:label id="lblMessage2" runat="server" width="288px" font-bold="True" font-italic="True"
font-size="Medium" forecolor="#C00000" style="left: -289px; position: relative; top: 259px"></asp:label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TOSHIBA1ConnectionString %>"
SelectCommand="SELECT [First_Name], [LOGIN_Id], [Password] FROM [Users]"></asp:SqlDataSource>
<!-- ||||| End of Form ||||| -->
</body>
</html>
i am getting the error in the data base connection it showing that u have not initilize the data base connection
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Login_page : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
#endregion
protected void Button1_Click1(object sender, EventArgs e)
{
if (Page.IsValid)
{
if (DBConnection(txtUserName.Text, txtPassword.Text))
{
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
Response.Redirect("wellcome.aspx");
}
else
{
lblMessage.Text = "Invalid Login, please try again!";
}
}
}
private bool DBConnection(string txtUser, string txtPass)
{
SqlConnection myConn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["<%$ ConnectionStrings:TOSHIBA1ConnectionString %>"]);
SqlCommand myCmd = new SqlCommand("sp_ValidateUser", myConn);
myCmd.CommandType = CommandType.StoredProcedure;
SqlParameter objParam1;
SqlParameter objParam2;
SqlParameter returnParam;
objParam1 = myCmd.Parameters.Add("[LOGIN_Id]", SqlDbType.VarChar);
objParam2 = myCmd.Parameters.Add ("[Password]", SqlDbType.VarChar);
returnParam = myCmd.Parameters.Add("[First_Name]", SqlDbType.VarChar);
objParam1.Direction = ParameterDirection.Input;
objParam2.Direction = ParameterDirection.Input;
returnParam.Direction = ParameterDirection.ReturnValue;
objParam1.Value = txtUser;
objParam2.Value = txtPass;
try
{
if (myConn.State.Equals(ConnectionState.Closed))
{
myConn.Open();
myCmd.ExecuteNonQuery();
}
if ((int)returnParam.Value < 1)
{
lblMessage.Text = "Invalid Login!";
return false;
}
else
{
myConn.Close();
return true;
}
}
catch (Exception ex)
{
lblMessage2.Text = ex + "Error Connecting to the database";
return false;
}
}
}
|
|
|
|
|
What line did you get your error on? Have you got a connection string in the config file?
|
|
|
|
|
Nothing understandable. Please post properly
|
|
|
|
|
Go to your admissions office, hand them back your student ID and tell them you're too stupid to be on this course. Then go home stand in front of a mirror and repeat these lines 100 times "Would you like fries with that, Sir".
|
|
|
|
|
Just to add, it's idiots like you that are killing our industry, especially when you start taking jobs through sites like rentacoder and cause end users to assume that this level of cluelessness is what our industry is about. If this is not homework, but a paid job, then contact the client, tell them you were stealing from them, and return their deposit.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
...
"Well, we're getting "F"'d at work. WPF, WCF, and WWF... WTF?" --John Simmons
|
|
|
|
|
i have parent datagrid and a child datagrid nxt row of everydataitem. when i click the expand button in parent dg the child dg will be shown.
my problem is when i clicked edit button or any button in child datagrid my parent datagrid collapse. how can i maintain the expanded child datagrid?
this is my code snippet
<code><script type="text/javascript">
function expandcollapse(obj){
var div = document.getElementById(obj);
var img = document.getElementById('img' + obj);
if (div.style.display == "none"){
div.style.display = "block";
img.src = "images/collapse.gif";
img.alt = "Close to view sub menus";
}else{
div.style.display = "none";
img.src = "images/expand_blue.gif";
img.alt = "Expand to show sub menus";
}
}
</script>
<asp:datagrid id="grdMenu" runat="server" width="830px" autogeneratecolumns="False">
<columns>
<asp:templatecolumn headertext="Menu Title" sortexpression="mainmenuid">
<itemtemplate>
<asp:label id="lblmenutitle" runat="server" />
</itemtemplate>
</asp:templatecolumn>
<asp:templatecolumn>
<itemtemplate>
<a href="javascript:expandcollapse('div<%# Eval(" mainmenuid=") %>');">
<img id="imgdiv<%# Eval(" mainmenuid=") %>" src="images/expand_blue.gif" /></a>
<tr><td colspan="100%">
<div id="div<%# Eval(" mainmenuid=") %>">
style="display:none;position:relative;left:25px;OVERFLOW: auto;WIDTH:98%;" >
<asp:datagrid id="grdSub" runat="server" autogeneratecolumns="False" cssclass="InputText" datakeyfield="mainmenuid" onpageindexchanged="ChangeIndex2" ondeletecommand="grdSub_DeleteCommand" onupdatecommand="grdSub_UpdateCommand" oneditcommand="grdSub_EditCommand" onsortcommand="grdSub_SortCommand" onitemdatabound="grdSub_ItemDataBound">
<columns>
<asp:templatecolumn headertext="SubmenuTitle">
<itemtemplate>
<asp:label id="lblparentid" runat="server" />
</itemtemplate>
</asp:templatecolumn> <asp:templatecolumn> <itemtemplate><asp:imagebutton id="ImageButton6" runat="server" imageurl="~/images/edit.gif" commandname="Edit" causesvalidation="false"></asp:imagebutton>
</itemtemplate></asp:templatecolumn>
</columns></asp:datagrid>
</div></td></tr></itemtemplate>
</asp:templatecolumn>
</columns></asp:datagrid></code>
thanks in advance.
|
|
|
|
|
Hi,
I am using the Infragistics calendar view control for displaying the booking activity...
I need to pass the date & time along with the parameter from the parent page to the child page.
Please help me in fetching the date & time through javascript and pass it as a parameter to the child window.
Thanks for your quick response.
Regards
Priya
|
|
|
|
|
Please guide me if any one have any solution.
|
|
|
|
|
I have a datagrid with AutoGenerateColumns="True". I also have 3 template columns in the datagrid. One with a checkbox for multiple selection of rows.
Now I need to iterate through the grid to know which are the rows selected.
But when I try to iterate like below:
foreach(DataGridItem i in grdResults.Items)
{
bool bChecked = ((CheckBox)i.FindControl("chkSelect")).Checked;
if(bChecked == true)
{
string locationTxt = ((TextBox)i.FindControl("txtLocation")).Text;
}
}
grdResults.Items gives "error: cannot obtain value"
I am not sure what is going wrong. I want to use autogeneratecolumns since the datasource is bound to ds.tables[2] and template columns since some of the data is bound to ds.tables[0] and tables[1].
Please help. Thanks in advance.
|
|
|
|
|
you better do a
foreach (Datarow row in grdResults.Rows)
you scan all the rows in the gridview.
than do a row.FindControl(). What you do now is checking each item and if the item is chkSelect. If it is not chkSelect you have a null reference. Only 1 item in each row is chkSelect, not all items in the grid can be chkSelect.
|
|
|
|
|
How to save an grid values in database (sql server 2005)at runtime..
Is there any link refer to me..
Thanx in advance..
|
|
|
|
|
|
|
No i dont want to edit,update,select command.For example if i am loading an xml file to the project during run time.that particular file details must stored in database automatically...
help me.
Thanx in advance.
|
|
|
|
|
in general you can export your xml data to sqlserver using SSIS(Integration Service)
but if you mean that your xml data binded to a grid and you want to insert these data into sqlserver from your grid, i think you can generate a datatable from your grid data, and then insert your datatable into sqlserver table completely.
|
|
|
|
|
for asp.net 2.0 What is difference between following methods for selecting XML data. which one is better interms of performace.
1) Dataset.select
2) dataview
3) xmlDocument.SelectNodes
4) xmlNavigator.select
modified on Monday, January 19, 2009 2:41 AM
|
|
|
|
|
Member 3981366 wrote: Dataset.select
There is no Select method in DataSet class. Also, DataSet is not designed for XML manipulations.
Member 3981366 wrote: dataview
What this has to do with XML?
Member 3981366 wrote: xmlDocument.SelectNodes
XMLDocument.SelectNodes or XMLDocument.SelectSingleNode with XPath expression will be fast.
Member 3981366 wrote: xmlNavigator.select
AFAIK, this class is no longer used.
|
|
|
|
|
Hi to all,
I have a datagrid in which there is a checkbox and a textbox.
The user can change the value in textbox.
below there is update button.When the user presses the update button
the textbox value should be updated.
For this I have done this:
protected void BtnUpdate_Click(object sender, EventArgs e)
{
dt = (DataTable)Session["data"];
DataGrid2.DataSource = dt;
DataGrid2.DataBind();
CheckBox chkSelected = new CheckBox();
foreach (DataGridItem dgItem in DataGrid2.Items)
{
chkSelected = (CheckBox)dgItem.FindControl("chkSelection");
if (chkSelected.Checked != true)
{
TextBox TxtQTY = (TextBox)dgItem.Cells[2].FindControl("TxtQTY");
string Txt2 = TxtQTY.Text;
}
else
{
int a = 1;
}
}
}
The problem is that this functionality is not taking the user input.
In the starting I have done databing because of which it is taking the previous value.But if I will not bind the data It is not going in the foreach loop to check wether any checkbox is selected or not as in debugging it is showing that the item collection in the datagrid is empty.
Please give some suggestions...
Thanks in advance.
cheers,
sneha
|
|
|
|
|
sneha Choudhary wrote: dt = (DataTable)Session["data"];
DataGrid2.DataSource = dt;
DataGrid2.DataBind();
Problem is in above code.
You are rebinding DataGrid before fetching new values from textbox. This will over write all the previously entered text.
Try moving this code after you have read value from textbox
|
|
|
|
|
Why is the datagrid losing all the items. You may be doing something before reaching to this event.
Apurva Kaushal
|
|
|
|
|
sneha Choudhary wrote: DataGrid2.DataSource = dt;
DataGrid2.DataBind();
This will clear the values changed in the textbox. Why do you need to rebind the grid?
sneha Choudhary wrote: //if I will not bind then it will not go in foreach loop.
//as it will not find any items in the datagrid.
Which event are you using for binding the grid? Is viewstate enabled for this control?
|
|
|
|
|
Hi,
I got the problem.Actually It was regarding the postback.
Thanks a lot.
cheers,
sneha
|
|
|
|
|
Hello everybody..in my application i have to show a indication whether i am connected to internet or not..
|
|
|
|