|
Every Grid is bound to a DataTable.
You store the datatable in memory, when user request a row delete from grid. Remove the Row from datatable and rebind table to grid.
|
|
|
|
|
But is it possible to delete it without storing the datatable to memory?
Prabhuram Natarajan
|
|
|
|
|
Amandeep Singh Bhullar wrote: Every Grid is bound to a DataTable.
This is not correct.
GridView/DataGrid can take any IEnumerable type as data source.
|
|
|
|
|
Hi, i am reading data from csv file to datatable. But some data is not reading. if the columns contains data with hyphens "234-456" is not reading. if hypen appears in text like 'sat-ish' is reading...why?
if (_fileexten == ".csv")
{
string str = Path.GetFileName(_filename);
OdbcConnection conn = new OdbcConnection("Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + _fpath + "\\;Extensions=asc,csv,tab,txt;Persist Security Info=False");
conn.Open();
string sql_select = "select * from [" + str + "]";
OdbcDataAdapter myCommand = new OdbcDataAdapter(sql_select, conn);
myCommand.Fill(myDataSet, "csv");
dt = myDataSet.Tables[0];
conn.Close();
myCommand.Dispose();
}
G. Satish
|
|
|
|
|
Well, I think the OleDbProviders chooses according to the no of occurance basis.
To honor mixed mode, I think you need to include some Extended properties.
Use
Extended Properties=HDR=YES;IMEX=1
IMEX = 1 will honor mixed mode and choose everything as string.
To do that you also need to set the registry engine
HKLM\Software\Microsoft\Jet\4.0\Engines\YourEngine\ImportMixedTypes = Text
This fixed once, to me.. hope this works for you too...
Abhishek Sur
|
|
|
|
|
I'm filling a dropdownlist using an update panel. Following is the code:
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:DropDownList ID="CompanyList" runat="server"
Height="22px" Width="155px" AutoPostBack="True" AppendDataBoundItems="true"
onselectedindexchanged="CompanyList_SelectedIndexChanged" >
<asp:ListItem Selected ="True" Text="--Please Select--"></asp:ListItem>
</asp:DropDownList>
<br />
<asp:DropDownList ID="ProjectList" runat="server" AppendDataBoundItems="true"
Height="23px" Width="155px" >
<asp:ListItem Selected ="True" Text="--Please Select--"></asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress2" AssociatedUpdatePanelID="UpdatePanel2" runat="server" >
<ProgressTemplate>
<span class="ProgressBar">
Data Loading. Please Wait....</span></ProgressTemplate>
</asp:UpdateProgress>
Everything is working fine and data is populating in both the dropdownlists without postbacks. After saving the data, I need to clear the dropdownlist by keeping the item "--Please Select--". When I say, ProjectList.Items.Clear();, all the items are getting cleared. I am not sure how to achieve this. Anybody please provide any help on this.
Thanks,
|
|
|
|
|
meeram395 wrote: ProjectList.Items.Clear();, all the items are getting cleared
it will clear all the Items.
You can achieve your task using two differnt ways
Firstly,
After clearing the Dropdown add new item "--Please Select--"
Secondly,
Try using method Remove or RemoveAt or list.Items
|
|
|
|
|
Thank you. i have added it again and it worked. Thanks a lot.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Thank you. I have added it again and it got worked.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Hi, Iam using Repeater control in my Project. I want to get the specified values from the row when the clicked? Can u give the code or any Idea? Its urgent. pls...
karthick_gc
|
|
|
|
|
Karthick_gc wrote: Its urgent. pls...
Yeah I know
Since it is urgent, I can give you a hint. No server side events are fired when an item is clicked in the repeater. Work with JS and use the click event.
|
|
|
|
|
In case of repeaters, the item template will repeat for each data as HTML during rendering process.
You can have to find a mechanism to detect the row from html. Place the ID of the row within one of your control's attributes, so that you could find that when user clicks the control.
If the control is a button, you can use ItemCommand event handler from the serverside.
You can use ((Button)e.CommandSource) from the Repeater_OnItemCommand EventHandler to find the button within the repeater.
Abhishek Sur
|
|
|
|
|
Hi to all,
I am stucked in updating a datagrid when user changes the textbox value.
I am binding the datagrid through a datatable.
What I am doing is:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Mycart : System.Web.UI.Page
{
float total_Price = 0;
int total_items = 0;
int quanti;
string pro_id;
string desc;
string id;
int qty3;
float unitprice;
float cost;
DataTable dt;
DataTable dt2;
DataGridItem dgItem;
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
if (Session["Cart"] == null)
{
dt = new DataTable();
dt.Columns.Add("REF", typeof(string));
dt.Columns.Add("Description", typeof(string));
dt.Columns.Add("QTY", typeof(int));
dt.Columns.Add("Price", typeof(float));
dt.Columns.Add("Cost", typeof(float));
get_data();
Session["Cart"] = dt;
}
else
{
dt = (DataTable)Session["Cart"];
get_data();
Session["Cart"] = dt;
}
}
}
public void get_data()
{
pro_id = Request.QueryString["pr_id"];
quanti = Convert.ToInt32(Request.QueryString["quant"]);
if (pro_id != null)
{
SqlConnection con = new SqlConnection("Server=.; Database=eclsc; Trusted_Connection=yes");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select ICEMACHINES.product_id,ICEMACHINES.sh_desc,ICEMACHINES.price from ICEMACHINES where ICEMACHINES.product_id LIKE @product_id union select GLASSWARE.product_id,GLASSWARE.sh_desc,GLASSWARE.price from GLASSWARE where GLASSWARE.product_id LIKE @product_id ";
cmd.Parameters.Add("@product_id", SqlDbType.NVarChar, 50).Value = pro_id;
cmd.Connection.Open();
SqlDataReader rdr = cmd.ExecuteReader();
ArrayList arRole1 = new ArrayList();
while (rdr.Read())
{
desc = (rdr["sh_desc"]).ToString();
id = (rdr["product_id"]).ToString();
unitprice = Convert.ToSingle((rdr["price"]));
cost = unitprice * quanti;
}
cmd.Connection.Close();
DataRow myrow = dt.NewRow();
myrow["REF"] = id;
myrow["Description"] = desc;
myrow["QTY"] = quanti;
myrow["Price"] = unitprice;
myrow["Cost"] = cost;
dt.Rows.Add(myrow);
dt.AcceptChanges();
Session["data"]= dt;
DataGrid2.DataSource = dt;
DataGrid2.DataBind();
}
else
{
int a = 1;
}
total_items = total_items + quanti;
total_Price = total_Price + cost;
Session["items"] = total_items;
Session["value"] = total_Price;
}
protected void BtnUpdate_Click(object sender, EventArgs e)
{
dt = (DataTable)Session["Cart"];
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");
int Txt2 = Convert.ToInt32(TxtQTY.Text);
Label lblProduct_Id = (Label)dgItem.Cells[0].FindControl("lblProduct_Id");
string id2 = lblProduct_Id.Text;
Label lblDescription = (Label)dgItem.Cells[1].FindControl("lblDescription");
string desc2 = lblDescription.Text;
Label lblPrice = (Label)dgItem.Cells[3].FindControl("lblPrice");
float price2 = Convert.ToSingle(lblPrice.Text);
Label lblCost = (Label)dgItem.Cells[3].FindControl("lblCost");
float cost2 = Convert.ToSingle(lblCost.Text);
float final_cost = price2 * Txt2;
DataRow myrow = dt.NewRow();
myrow["REF"] = id2;
myrow["Description"] = desc2;
myrow["QTY"] = Txt2;
myrow["Price"] = price2;
myrow["Cost"] = final_cost;
dt.Rows.Add(myrow);
dt.AcceptChanges();
Session["data"] = dt;
}
}
DataGrid2.DataSource = dt;
DataGrid2.DataBind();
}
protected void BtnSave_Click(object sender, EventArgs e)
{
}
protected void BtnRetrieve_Click(object sender, EventArgs e)
{
}
protected void BtnContinue_Click(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx");
}
protected void BtnCheckout_Click(object sender, EventArgs e)
{
Response.Redirect("Checkout.aspx");
}
}
Through this functionality I am able to update the datagrid but the problem is:
Suppose a user added two items in the datagrid.Then he checks one of the row to update.Then after updating it is showing three items.Instead of updating the same row it is adding the updated row below the previous two entries.
I am unable to get rid of this problem.
Thanks in advance.
cheers,
sneha
|
|
|
|
|
Hi to all,
I have a datagrid in I am having a checkbox in every row.What I want to do is
to delete the row from the datagrid for which checkbox is checked.
How to find index of the datagrid which is checked?
How to delete that particular row from the datagrid?
It is not interecting with the database.
Thanx in advance.
cheers,
sneha
|
|
|
|
|
I need to create a Menu with 3 level in my web application using Menu Control in ASP.net.
Can someone tell how should I build my database structure, queries and in C# to do so.
Ex :
Menu1
|_ Menu1_1
|_ Menu1_2
Menu2
|_ Menu2_1
|_ Menu2_2
|_ Menu2_2_1
|_ Menu2_2_2
|
|
|
|
|
Try Java script. It is easy to create any type of Menu.
|
|
|
|
|
Dear friend i have the concept of Url rewriting.
But stuck when go for coding.I need code in c# for Url Rewriting.
Please help me
|
|
|
|
|
Don't re-invent the wheel. Use opensource programs like this[^]. It is tested and proven performance. You can get it working with minimum effort.
|
|
|
|
|
I have implemented Google maps on to an ASP .net web page. I have referenced the Google Map API also.
I want to know some issues before going to deploy it.
I do not have access to www.maps.google.com , then how can I get the google maps get loaded into my ASP .net application.
SAJAN A PILLAI
ASP.NET,C#.NET Programmer
BANGALORE
"Winners don't do different things. They do things differently. ...
|
|
|
|
|
codingrocks wrote: I do not have access to www.maps.google.com , then how can I get the google maps get loaded into my ASP .net application.
How can you expect that?
|
|
|
|
|
Uh, copy the entire contents of www.maps.google.com servers from another workstation that does have access to it and then put it on your multi-million dollar servers . . .?
OK, I'm being a crass (minus the "cr").
If you have no access to maps.google.com (note that you do not need the "www."), then you necessarily can not incorporate it into your .NET application.
If your development workstation has no access to to maps.google.com, but the server wherein your .NET application does have access, then that's a predicament for you.
GN
ASPX ~ Apple Simply Performs Xcellently
|
|
|
|
|
Hi,
I have written the javascript function in the External js file and named it as JScript.js. This file is in Javascripts folder which under the Project folder.
The JScript.js file contains the following code.
// JScript File
function validateParameter()
{
var paramname=document.getElementById('<%=txtParam.ClientID %>');
var message;
message="";
if(paramname.value=="")
{
message+="\n*Parameter Name is mandatory";
}
else if(paramname.value!="")
{
var alphaExp = /^[a-zA-Z\s]+$/;
if(!paramname.value.match(alphaExp))
{
message+="\n*Only Alphabets are allowed for Parameter Name";
}
}
if(message!="")
{
alert(message);
return false;
}
return true;
}
I have called the javascript file using the below html tag.
I have called the javascript function for OnClientClick of a button.
OnClientClick="javascript: return validateParameter();"
But during the runtime the button click is not validating the controls.
Please Help Me! Thanks.
|
|
|
|
|
Best way is to install Firebug or use the Firefox error console to know what's wrong with your JS.
anandhakrishnan wrote: var paramname=document.getElementById('<%=txtParam.ClientID %>');
I am not sure, but I think the client id used in external JS will not get rendered. Have you checked? If it is not rendering, just pass the id as function parameter. Something like
function validateParameter(textBoxId)
{
var paramname = document.getElementById(textBoxId);
....
}
OnClientClick="javascript: return validateParameter('<%=txtParam.ClientID %>');"
|
|
|
|
|
anandhakrishnan wrote: I have called the javascript file using the below html tag.
I have called the javascript function for OnClientClick of a button.
OnClientClick="javascript: return validateParameter();"
First try with alert on that method and check weather its called or not.
Then
You should pass the clientID also to the ValidateParameter().
anandhakrishnan wrote: OnClientClick="javascript: return validateParameter();"
OnClientClick="javascript: return validateParameter(ClientID);"
|
|
|
|
|
Hi Experts,
I currently have a crystal report on live and if the report has parameters and the report would automatically prompt the user for the required arguments itself, i did not input the argument fields for user to enter but the report does it automatically but when I click "OK" it gives me a null reference exception.
How do I overcome this problem?
Thanks in advance! ^^
Cheers!
|
|
|
|