|
Gautham,
You don't need to import rows in this case. All you need to do is assign the table:
DataTable dataTable1 = DataSet.Tables[0];
This will work for sure.
|
|
|
|
|
Thanks for the reply!
However, there would be chances where my datatable might have few rows initially, now the rows from the databse should be added to existing rows of the datatable.
That was the reason i have used import row
Gautham
|
|
|
|
|
If you are using DataSet to get the data from the database you might as well want to make the datasource as:
private void BindData()
{
dataGrid1.DataDource = DataSet.Tables[0];
dataGrid1.DataBind();
}
This way when new rows are added, as soon as the dataset it updated, just call the BindData() method and the grid will refresh.
|
|
|
|
|
Hi,
Let me enunciate a bit further that would be useful in identifying my concern.
Now the user, would enter few details on a web page and would click 'Add', the details would be orderno, date, etc etc.
The moment he clicks the add we have to display few details in a grid according to the orderno entered, this order info is being retrieved from the database.
So if the user is clicking add button 10 times 10 records should be displayed in the datagrid and all 10 times i would go the databse and get the order info.
This is the reason i created a datatable and bound it with a datagrid. when ever a new order is being added that info should be added to the datatable and finally show in a datagrid!
Hoping i was clear!
Gautham
|
|
|
|
|
HI,
Your code should look like as following.
foreach ( DataRow row in dst.Tables[0].Rows )
{
dt.ImportRow( row );
}
Try this.
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Chetan,
Actually i did the same thing but the following error is being thrown:
DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name OrderId
Gautham
|
|
|
|
|
Hi,
This is not the code error. It happens because u might have given wrong column name or both of your tables dont have the same columnnames and same number of columns and the same order of columns.
Check for that once.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Hello to every one,
What this error means and how to solve this error...
"Control 'RequiredFieldValidator1' of type 'RequiredFieldValidator' must be placed inside a form tag with runat=server. "
|
|
|
|
|
that means you need to add this attribute (runat=server) in your control.
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
Go to the "Source" of your aspx file and add 'runat = "server"' tag to the RequiredFieldValidator. That should fix the problem.
|
|
|
|
|
The form tag missing from your code.
the RequiredFieldValidator must be inside the form tag
Like
Place your Html and valdation related code here
manojchilhate
|
|
|
|
|
|
hi
Looking for a bit of help. I have an asp.net listbox. I am wanting to manually be able to order the box by clicking a button. got everything set up but I keep getting an error saying that I can't have multiple selections on the list box when it is set as a single selection. I don't really know where I am going wrong so if anyone can help me I would most appreciate it. My code for the button click is as follows.
Protected Sub btOrderElementUp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btOrderElementUp.Click<br />
If ltbOrderByList.Items.Count() = 0 Or ltbOrderByList.Items.Count() = 1 Then<br />
Exit Sub<br />
End If<br />
<br />
Dim liItem As ListItem<br />
Dim intItemIndex As Integer<br />
<br />
liItem = ltbOrderByList.SelectedItem<br />
intItemIndex = ltbOrderByList.SelectedIndex<br />
ltbOrderByList.Items.Insert(intItemIndex - 1, liItem)<br />
ltbOrderByList.Items.RemoveAt(intItemIndex)<br />
ltbOrderByList.ClearSelection()<br />
ltbOrderByList.SelectedIndex = intItemIndex - 1<br />
<br />
End Sub
The last two lines are my attempt to manually set the selected item so multiple items definitly aren't selected. If there is an easier way of doing this I would also appreciate it if you could tell me too!
Cheers
Ian
|
|
|
|
|
try this instead of
Senseicads wrote: ltbOrderByList.ClearSelection()
ltbOrderByList.SelectedIndex = intItemIndex - 1
ltbOrderByList.Items[ltbOrderByList.SelectedIndex].Selected = false;
ltbOrderByList.SelectedIndex = intItemIndex - 1
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
Thanks
I was able to just set the selected to true after my clearselection. Thanks for the help.
<br />
ltbOrderByList.ClearSelection()<br />
ltbOrderByList.Items(intItemIndex - 1).Selected = True
So is it not possible to use selectedIndex like I was attempting to then? The intellisense says that SelectedIndex is used to "get or set" the index of the selected item?
cheers
Ian
|
|
|
|
|
Hello To Everyone,
i want to declare a static variable in Asp.net which sholud also be a global variable.
Fr eg. i declared
static name as string
but when i declare it general section it gives me an error.
if i use public then i 'm unable to make it static variable
-- modified at 6:51 Monday 18th June, 2007
|
|
|
|
|
Create a static class
static MyClass
{
public static string _MyString;
}
you can access the above using the following:
String s = MyClass._MyString;
|
|
|
|
|
hello,
thanx but i need to code in vb..
could u help me out
|
|
|
|
|
In VB you can say "Shared" instead of "static".
|
|
|
|
|
|
Hi,
I'm toying around with an idea for a project but in order to get started I'd need to be able to access the HTML produced for an ASP.NET page from a function within that page.
Does anyone know if this is even possible - I was thinking if I wrote a custom http handler I might be able to do something along those lines....?
Cheers
Dave
|
|
|
|
|
Check for WebClient. Using this class you can get the HTML code for any webpage.
|
|
|
|
|
Is there any way you could render the page twice? Once to the output stream, once to a string variable?
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman"
(Lilly Allen / Kaiser Chiefs)
|
|
|
|
|
Yes, you can do that by overriding Page.Render()[^]
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
After a bit of playing about I've decided to go a slightly different route - instead I create a new Page object in memory add an HtmlForm and then add the (now customisable list of) controls from the original form to it. I can render in memory and retrieve the HTML using the <code<rendercontrol< code=""> method.
It caught me out at first but since I've added objects to a temporary page, they get removed from the original page at the same time! A quick <code>Dictionary<Control, int> to store the index they occupy on the original form lets me add them back across at the end.
HTH
Dave
|
|
|
|