|
Nopo wrote: DataRow dr = new DataRow();
Why are you doinh this.
1. Create DataTable.
2. Assign Columns to it.
3. Create a DataRow by dt.NewRow().
4. Fill that row and add it to datatable.
|
|
|
|
|
Thanks. Here it is now:
//Create DataTable.
DataTable dt = new DataTable();
//Assign Columns to it.
dt.Columns.Add(new DataColumn("Full Names"));
dt.Columns.Add(new DataColumn("Identifying Number"));
dt.Columns.Add(new DataColumn("Passport Number"));
//Create a DataRow by dt.NewRow().
DataRow dr = dt.NewRow();
//Fill that row and add it to datatable.
dr["Full Names"] = txtFirstName3.Text;
dr["Identifying Number"] = txtIdentityNo.Text;
dr["Passport Number"] = txtPassportNo.Text;
dt.Rows.Add(dr);
//Bind GridView Here with this Table
this.dgInfoProfile.DataSource = dt;
dgInfoProfile.DataBind();
I'm making a huge progress now.
After clicking ADD button, the gridview is showing with all the column names but the data captured from the textboxes is not being saved to the gridview.
I'll double check and see if there're any typing errors.
|
|
|
|
|
sure, tell me if it works.
|
|
|
|
|
Its now working perfect. I think the problem was that I turned the AutoGenerateColumns to "false" because after changing it to "true" it worked.
Thanks a lot for all the guidance you've given me.
|
|
|
|
|
If his answer helped you then please vote/rate the messages which helped you.
Thanks !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Great.
|
|
|
|
|
The answer is gr8 been struggle the whole day..thanx
|
|
|
|
|
Forgive me for being confused here, but this actually won't work if you want to keep adding to the datatable based on multiple selections from the textboxes, listboxes and dropdownboxes - right? This will only populate the datagrid once and then re-populate it on each click of the Add button?
|
|
|
|
|
Hi,
I'm looking for a control that does exactly the same as the control used on The Code Project for setting newsletter topics (see http://www.codeproject.com/script/Membership/Modify.aspx tab "Newsletters").
The control, when not selected, shows a comma separated list of newsletter topics. When you click the control it comes up with 4 columns of checkboxes in which you can select and deselect the newsletter topics you're interested in.
Any clues?
|
|
|
|
|
This is Nothing but a DIV . Place all the control inside DIV. Hide/Show Div on the click on TextBox
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Thank you.
You wouldn't happen to have some html / ASP.NET markup would you (especially of the controls used within the DIV)?
I guess the "Hide/Show Div on the click on TextBox" has to be done with Javascript (to prevent a postback)? A small sample script would help a lot.
Thanks for your help.
|
|
|
|
|
Gebbetje wrote:
I guess the "Hide/Show Div on the click on TextBox"
You can do it using simple JavaScript.
Here is the sample javascript :
var counter =0;
function ShowHideDiv()
{
var DivID=document.getElementById('MyDiv');
if(counter == 0)
{
DivID.style.display ="Block";
counter=1;
}
else
{
DivID.style.display ="none";
counter=0;
}
return false;
}
Note: You can also do it without using counter, just check div visibility when you are checking the counter.
Hope this will help you
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I have a treeview in my form. I need to get the nodes count of the treeview using javascript. I know it is possible in code behind. But I want to do it in javascript.
I used the following code,but getting an error that "controlid.Nodes.length" is null or not an object.
var controlid = document.getElementById('ctl00_MainContent_CreateWizard_UnitsTreeView');
var nodecount = controlid.Nodes.length;
alert(nodecount);
Any idea how to get the count of nodes? Please help.
Thanks,
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Why do you require this using javascript.
treeview renders nested tables. So you need to use javascript to count tables.
why dont you count in the server side and store in an hidden field ?
|
|
|
|
|
The treeview is rendered as a table, so there is no easy way to get a count of nodes - the nodes are actually table rows and cells.
You could apply a css class or other attribute to the nodes in the code behind when you are creating your treeview - then use javascript to count the number of elements with that class - very simple if you use JQuery.
Are you adding or removing nodes dynamically with javascript? If not then you could just count them as they are added server-side and embed them in your javascript when the page is rendered. This[^] post will show you how to embed asp.net variable.
Hope that helps.
|
|
|
|
|
hii
all.i have stored images in database by giving their path.now i want to show the images in datalist.
tell me how can i do this......plz guide....
thnks in advc....
|
|
|
|
|
You have to read that image in a byte array.
I suggest you to search on google, you'll find many helpful articles.
|
|
|
|
|
No, he doesn't. He's stored a path, he can just pass that path to an img tag.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Oh i am sorry, i didn't noticed that.
|
|
|
|
|
Here is one of my article which showing image from database to gridview.
Displaying Image in Gridview from Database[^]
Hope, you can also do the same for datalist.
Thanks !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
u just give the path of the image where u need to display
|
|
|
|
|
Hello,
I suggest you use "Asp:Repeater". Put img in the container and then bind the img source to your database.
|
|
|
|
|
here is my query and i use it for making a crystal report when i run it in database MS Access it show the values but same query when i run it in sql server it show error "The text,ntext and image data type cannot be compared or sorted except when IS NULL or LIKE"
there are its datatypes
TotalSale int
Price money
Category Text
Transaction Text
same datatype used in sqlserver and MS access. Plz help
SELECT Sum(b.TotalSale*b.Price) AS total, a.Category , a.[Transaction]
FROM TransactionType AS a INNER JOIN CouponTransaction AS b ON a.TransactionTypeID = b.TransactionTypeID
GROUP BY a.Category,a.[Transaction];
|
|
|
|
|
You can't GROUP BY a field of type text .
You could cast Category to a varchar , but that would not perform well.
Are you sure that the type text is the most appropriate for your data? A varchar might be much better and your GROUP BY would then work.
|
|
|
|
|
thnx Nigel now its working when i change its datatype.
again thank u very much
|
|
|
|