|
 |
|
|
Hi... my problem is, I could completely work the code out for me, but when I click on "Insert", I am not able to get any event so that I could write my db command to insert that data into the database!! dont know where I am going wrong.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
On the following statement I am getting Cast Specified not Valid exception.
EditCommandColumn ecc = (EditCommandColumn)grid.Columns[0];
any idea why is it happening ?
regards
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I was able to resolve. The mistake I was doing was, I had the edit in column 7 whereas I was putting 0. You have forgive me for my ignorance.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
first of all, thank you so much for the tutorial 
and please if you wouldn't mind, could you explain how to insert a record into 2 tables?
|
| Sign In·View Thread·PermaLink | 1.80/5 (2 votes) |
|
|
|
 |
|
|
please be more specific. 2 tables on the DB leel or inserting rows to two tables on the GUI level?
a) in the GUI (grid) you can have data's from more than one table. inserting and reading works the same way as here. after finishing editing, you have to open a db connection, create a transaction and insert the rows to the 1st then to the 2nd table, then do a commit)
b) if you have 2 grids on the asp.net form, i think it's possible to put the 2 grids into editing phase, although the 2 grids will for sure work separated...
hope this will help you.
C#, ASPX, SQL, novice to NHibernate
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
just like you read the values of any cells you're updating. you have to reference the TextBox components used to enter the data, and use the Text property.
C#, ASPX, SQL, novice to NHibernate
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
It is working fine, but i am unable to insert the data into my database as well as unable to update and delete
can u give me the full solution for that
Elavarasu
|
| Sign In·View Thread·PermaLink | 1.43/5 (4 votes) |
|
|
|
 |
|
|
Even with the change of the EditCommandColumn UpdateText to Insert, e.CommandName in the grid_ItemsCommand method still resolves as "Update", not "Insert".
Any ideas on a way to distinguish between the two?
Thanks in advance,
Scott
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
To fix this issue evaluate the text of the LinkButton. Switch the code in the switch box to ((LinkButton)e.CommandSource).Text.ToString().
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
I tried using (LinkButton)e.CommandSource).Text in the switch statement of the ItemCommand event handler but I'm still getting the Text as "Update" and not "Insert". My guess is that since the Page is constructed on each request to the server,the change to the text which was made in the Add button event handler is not perisisted across Postbacks, any suggestions/thoughts?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Yes there is a defect in the switch statement. I am using PushButton and not the LinkButton. Here is what I had to do to get the Switch to work correctly
//switch (e.CommandName) switch (((System.Web.UI.WebControls.Button)e.CommandSource).Text) { case "Insert": //Get the new string from the textbox string newInsTxt = ((TextBox)e.Item.Cells[1].Controls[0]).Text; //Do the insert Insert(newInsTxt); break; case "Cancel": EditCommandColumn ecc = (EditCommandColumn) StatusDataGrid.Columns[0]; ecc.UpdateText = "Update"; break;.......
The addButton_Click method set the text of the button on the DataGrid to "Insert" so without the switch looking at the button text correctly, it would never hit the Insert case.
Now the only issue is that that I get two postBack's in the case statement.
Bruce Ellis
|
| Sign In·View Thread·PermaLink | 3.50/5 (2 votes) |
|
|
|
 |
|
|
How to change this to VB code? Any idea? Because I having problem in casting EditCommandColumn to grid.columns(0)
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
Sorry, have too little VB.NET experience...have you tried: Dim o as Object Set o = grid.columns(0) as EditCommandColumn
By the way, what's the exception or what kind of error do you get?
|
| Sign In·View Thread·PermaLink | 2.00/5 (3 votes) |
|
|
|
 |
|
|
Nice article and a elegant solution. Is there a way to font/font size for the editing/inserting cells ? they don't match with the rest of the grid.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
you can set the style of the grid through css classes, but the template columns contains textbox (or may contain any other) controls. for them you need to set the css class separately.
<b>Just examine the HTML below:</b> <asp:TemplateColumn HeaderText="Any text for header"> <HeaderStyle Width="52px"></HeaderStyle> <ItemTemplate> <asp:RadioButton id=rbA CSSCLASS = "anyCSSClass" Text='<%# DataBinder.Eval(Container.DataItem, "pristup") %>' Runat="server" GroupName="P"> </asp:RadioButton> </ItemTemplate> <EditItemTemplate> <asp:RadioButton id=rbEditA Text='<%# DataBinder.Eval(Container.DataItem, "pristup") %>' Runat="server" GroupName="G"> </asp:RadioButton> </EditItemTemplate> </asp:TemplateColumn>
C#, ASPX, COM, SQL
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
what I meant was is there a way to change font of the text box in your code (for the edit/insert cells) at the run time ? I don't think you were using template column, right ?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Very good article and elegant solution. One question though: Can I change font or font size in the edit cells/insert cells ? It seems they don't match Css I set for the Grid.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
On the following statement I am getting Cast Specified not Valid exception.
EditCommandColumn ecc = (EditCommandColumn)grid.Columns[0];
any idea why is it happening ?
regards
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |