15,905,028 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Darsh12345 (Top 9 by date)
Darsh12345
4-Oct-18 1:48am
View
issue is query is working fine on mysql workbench but not displaying output on .net page
Darsh12345
24-Sep-18 5:58am
View
I want to display multiple values in autocomplete textbox separated by comma. how to do it?
Darsh12345
20-Aug-18 23:43pm
View
yes
Darsh12345
9-Jul-18 2:06am
View
still showing error
Darsh12345
18-Apr-18 1:14am
View
is this code right?
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
Dbconn.Open();
string str = "select id,dte from test order by id asc";
oda = new OracleDataAdapter(str, Dbconn);
oda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
catch (Exception ex)
{
}
Darsh12345
18-Apr-18 0:54am
View
removed.
but not dispaying grid view.
only displaying current date, change date, delete and ascending button
Darsh12345
18-Apr-18 0:37am
View
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OracleClient;
using System.Configuration;
using System.IO;
using System.Net;
using System.Web.Caching;
using AjaxControlToolkit;
public partial class _Default : System.Web.UI.Page
{
OracleConnection Dbconn = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnEmp"].ConnectionString.ToString());
DataTable dt;
OracleDataAdapter oda;
OracleCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
txtcurrdate.Text = DateTime.Now.ToString("dd-MM-yyyy");
}
}
public void SetDate()
{
try
{
{
string str = "insert into test(dte) values('" + txtchangedate.Text + "')";
cmd = new OracleCommand(str, Dbconn);
if (Dbconn.State == ConnectionState.Closed)
{
Dbconn.Open();
}
cmd.ExecuteNonQuery();
lblmsg.Text = "Date Inserted Succesfully";
lblmsg.ForeColor = System.Drawing.Color.Green;
}
}
catch (Exception ex)
{
throw ex;
}
}
public void GetDate()
{
try
{
DataTable dt = new DataTable();
string str = "select id,dte from test order by id desc";
oda = new OracleDataAdapter(str, Dbconn);
oda.Fill(dt);
txtcurrdate.Text = dt.Rows[0]["DTE"].ToString();
GridView1.DataBind();
}
catch (Exception ex)
{
}
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
try
{
SetDate();
GetDate();
}
catch (Exception ex)
{
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
DataTable dt = new DataTable();
bool atLeastOneRowDeleted = false;
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox cb = (CheckBox)row.FindControl("dateselector");
if (cb != null && cb.Checked)
{
atLeastOneRowDeleted = true;
int id = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
Dbconn.Open();
OracleCommand cmd = new OracleCommand("delete from test where Id=" + id, Dbconn);
int result = cmd.ExecuteNonQuery();
GridView1.DataBind();
}
}
}
catch (Exception ex)
{
}
}
protected void Button2_Click(object sender, EventArgs e)
{
try
{
DataTable dt = new DataTable();
Dbconn.Open();
string str = "select id,dte from test order by id asc";
oda = new OracleDataAdapter(str, Dbconn);
oda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
catch (Exception ex)
{
}
}
}
Darsh12345
18-Apr-18 0:37am
View
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title>
<cc1:ToolkitScriptManager ID="scriptmanager1" runat="server" CombineScripts="True">
<asp:Label ID="lblmsg" runat="server">
<br \>
<asp:Label ID="Label1" runat="server" Text="currdate">
<asp:TextBox ID="txtcurrdate" runat="server" ReadOnly="true">
<asp:Label ID="Label2" runat="server" Text="changedate">
<asp:TextBox ID="txtchangedate" runat="server">
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd-MMM-yyyy"
TargetControlID="txtchangedate">
<asp:Button ID="btnsubmit" runat="server" Text="submit"
onclick="btnsubmit_Click" />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="HPCLMR"
CellPadding="4" ForeColor="#333333" GridLines="None" Width="228px">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<columns>
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True"
SortExpression="ID" />
<asp:BoundField DataField="DTE" HeaderText="DATE" SortExpression="DTE" />
<asp:TemplateField AccessibleHeaderText="select">
<itemtemplate>
<asp:CheckBox ID="dateselector" runat="server" />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
<!--<asp:SqlDataSource ID="HPCLMR" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnEmp %>"
ProviderName="<%$ ConnectionStrings:ConnEmp.ProviderName %>"
SelectCommand="SELECT ID, DTE FROM TEST order by id desc" >
-->
<asp:Button ID="Button2" runat="server" onclick="Button2_Click"
Text="Ascending" />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Delete" />
Darsh12345
18-Apr-18 0:29am
View
an error occured.
[InvalidOperationException: Both DataSource and DataSourceID are defined on 'GridView1'. Remove one definition.]
Show More