|
Hi eggsovereasy,
I am using vs 2003..and event handler is added like
"Protected WithEvents BtnUpdate As System.Web.UI.WebControls.Button"
and in the button click it handles BtnUpdate.Click...
When I click it is not going to the Page_Init or Page_load event also..
Pls help...
Thank You,
RPM.
|
|
|
|
|
I used vs 2003 even i faced same problem, but i sort out the problem by deleting the onclick button event and again redo btnclick event becoz sometimes the click event is not fired( for ex in vs 2003 when u rename the button on click event it takes oldername ratherthen new button name but i remove the code declared for oldbuttonname in codebehind then problem is solved)
|
|
|
|
|
Hi,
I had same problem,But I solved that partially.Now Add new button in panel where your current button is present,Double click on new button it will go to code part just write anything and keep Breakpoint on statement,run your application and See whether brekpoint execure or not,then reply me.
Regards,
|
|
|
|
|
Any idea why GridView.Columns.Count is 0 when the grid view actually has 13 columns and renders that way on the screen?
I'm trying to get the number of columns in the DataBound event if that matters.
|
|
|
|
|
GridView.Columns does not include columns that are automatically generated (i.e. AutoGenerateColumns="true" )
If you are automatically generating columns, then to get the column count you need to go to the datasource. If your datasource is a DataTable for example, you would do something like this:
DataTable dt = GetMyData();
MyDataGrid.DataSource = dt;
MyDataGrid.DataBind();
int numColumns = dt.Columns.Count;
|
|
|
|
|
Ahh I see... what I really need is the width of the columns. Let me explain what I am trying to do and maybe some has a suggestion.
I want to put a one row table right on top of the gridview so that it looks like it is part of that table and I want the columns on this "Topper" table as I'm calling it to line up with the columns on the gridview. More specifically I want one of the columns on the Topper table to be as wide as two specific columns on the gridview so that it sort of groups them together under another heading, and then another topper column to be as wide as 8 of the gridview columsn to group them together. So, I was attempting to get the widths of the columns in the gridview and then programatically set the width of the corresponding columns in the Topper table. I suppose I could just set up the columns manually and turn off AutoGenerateColumns.
|
|
|
|
|
Okay - you can probably get the effect you are looking for, but not in the way you're thinking now. Let me try to explain why. When the GridView renders, it is outputting <tr;> and <td> tags, so the widths in this context is managed by the browser. Even if you explictly added a Width attribute to the individual cells of the table row, say in an OnRowDataBound event handler, I'm guessing you won't get the results you are looking for - the browser may still decide to render widths differently in the two tables.
But you might consider adding your topper row to the underlying table in the gridview directly. You could do this with an event handler for the DataBound event of the gridView. Something like this:
void MyDataBound(Object o, EventArgs e)
{
Table t = gv.Controls[0] as Table
if (t != null)
{
GridViewRow heading = new GridViewRow(0, -1
, DataControlRowType.Header
, DataControlRowState.Normal
);
TableCell cell = New TableCell();
cell.Text = "My Spanning Heading";
cell.ColumnSpan = gv.Rows(0).Cells.Count;
cell.MergeStyle(gv.HeaderStyle);
heading.Cells.Add(cell);
t.Rows.AddAt(0, heading);
}
} and your markup for the gridview would assign OnDataBound:
<asp:GridView ID="gv" runat="server"
OnDataBound="MyDataBound"
/>
|
|
|
|
|
Adjusted the colspans and added some more cells and it works perfectly, thanks a lot for the tip!
|
|
|
|
|
|
How can i reflect changes in database through DataSet?
I have Items table with three columns[Item,UnitPrice,Quantity] in my database(mydb). I get that data in a DataTable through SqlDataAdapter. I create a DataRow), populate its fields, write it to the table, and call on AcceptChanges() method. But actually this row is not added to the table.
I wana reflect this change in table. The code is as under:
Sub Page_Load
Dim connString As String
connString="server=pc1;database=mydb;trusted_connection=true"
Dim conn As New SqlConnection(connString)
Dim cmd As New SqlCommand("Select * From Items",conn)
Dim adapter As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
conn.open()
adapter.fill(ds,"Items")
dim dr As DataRow=ds.Tables("Items").NewRow()
dr(0)="Item3"
dr(1)=44
dr(2)=44.4
ds.Tables("Items").Rows.Add(dr)
ds.Tables("Items").AcceptChanges()
adapter.Update(ds.Tables("Items"))
conn.Close()
MyDataGrid.DataSource=ds.Tables("Items")
MyDataGrid.DataBind()
End Sub
Thanks
|
|
|
|
|
don't call accept changes, the update runs on all rows marked as updated, which you wipe out when you call .AcceptChanges.
|
|
|
|
|
Thanks for reply. But none of these steps reflect changes in database.
|
|
|
|
|
Hi, I've tried to create a business object that can fully bind to the ObjectDatasource to be used in a DetailsView object for example. Everything works f ine here, but I cannot seem to get the deletemethod to do anything. This is the testobject I created:
public class BO
{
private int _id = 0;
public int Id
{
get { return _id; }
set { _id = value; }
}
private string _Field = string.Empty;
public string Field1
{
get { return _Field; }
set { _Field = value; }
}
private string _Field2 = string.Empty;
public string Field2
{
get { return _Field2; }
set { _Field2 = value; }
}
public BO() { }
public BO(string fld1, string fld2)
{
Field1 = fld1;
Field2 = fld2;
}
public BO LoadMe()
{
return (HttpContext.Current.Session["bo"] != null)?(BO)HttpContext.Current.Session["bo"]:new BO();
}
public void AddMe(BO bo)
{
HttpContext.Current.Session["bo"] = bo;
}
public void DeleteMe(BO bo)
{
BO InMem = (HttpContext.Current.Session["bo"] != null) ? (BO)HttpContext.Current.Session["bo"] : new BO();
if (InMem.Id == bo.Id) // Why is bo empty ??
HttpContext.Current.Session["bo"] = new BO();
}
I created a page with an objectdatasource, selecting LoadMe as the SELECT method, AddMe() as the INSERT method, and DeleteMe() as the DELETE method. The odd thing is that DeleteMe() fires, but the parameter bo is passed with just empty values..
Does anyone know what I'm doing wrong (if I'm doing something wrong) ?
Never mind the working of the object, I just need the Delete method to work.
tia,
Patt
-- modified at 10:37 Thursday 22nd June, 2006
|
|
|
|
|
Do you set the ID field in the DataKeyNames property of the DetailsView control?
|
|
|
|
|
That worked. Thanks. Eh, you wouldn't know how to keep it working even if I set the ID field readonly ?
|
|
|
|
|
Another option is that you can create the handler for the Deleting event of the ObjectDataSource control, in the handler you can set the Id or whatever property of the BO object stored in the e.InputParameters collection, this object is then passed to the Delete method as the parameter.
|
|
|
|
|
Hi Developers
I have been looking for Free AJAX enableb controls or Framework for ASP.net, but I dnt get any kool one. Most of these are commercial and very difficult to use.
Please let me know if you know about any simple+free AJAX enabled control for .NEt.
Note: I am using VB.net with ASP.net 1.1
Thanks in advance!
Lets work it Out.........!
-- modified at 10:37 Thursday 22nd June, 2006
|
|
|
|
|
!..Web Guru..! wrote: Most of these are commercial and very difficult to use.
hmmmm.....not a very good thing for a !..Web Guru..! to say...
You'll probably find that they're all pretty complex - in order to appeal to as wide an audience as possible, they must contain as many features as possible - meaning that they complicate quickly and tend to have fairly steep learning curves....
AJAX isn't difficult - why not try creating your own controls and components derived from the standard ones?
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
I have created a table on my page dynamically and in each cell I want to create a hyperlink that is invisible to the user but one 'clicked' will allow me to program the event in my code behind page which is vb.net? I cannot access the html code of the hyperlink as it is created on the fly.
From what I understand does the hyperlink not have an onclick event that can be responded to?
I am trying to mimic an excel spreadsheet with my table and want the user to click in a cell and have the background change to black to make the cell look selected.
I have this: (this is just part of it)
MyTable.Rows(i + 1).Cells(k + 1).BackColor = System.Drawing.Color.Black
Dim strHello As String
strHello = "Edit"
Dim e_link As HyperLink = New HyperLink
MyTable.Rows(i + 1).Cells(k + 1).Controls.Add(e_link)
If IsPostBack Then
MyTable.Rows(i + 1).Cells(k + 1).HorizontalAlign = HorizontalAlign.Center
e_link.ForeColor() = System.Drawing.Color.Black
e_link.Text = strHello
AddHandler e_link.Click, AddressOf e_link_Click
with this event handler placed lower
Private Sub e_link_Click(ByVal sender As Object, ByVal e As EventArgs)
Response.Write("You clicked Me!")
End Sub
Thanks
|
|
|
|
|
It would probably be simpler to achieve this using client side scripting. The problem will be that a) no OnClick event, and b) even if you do manage to catch SOMETHING, it'll need a postback to update the cell colour.
If you were to do it on the client side, you can assign an onclick handler to each element, then use a simple style.background='#xxxxxx' kinda thing to change the cell's background color.
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
I want to test the condition of whether or not the cell was clicked in and if it is presently a white background then change it to black to signify that it was selected.
How can I write that in vb.net? If the buttonlink does not yet exist untilt he page loads how can I access it from client script? Sorry if I appear stupid - I just may be. . . . . but hopefully just new to it all.
I have this so far:
If e_link.OnClick = True Then
if (e_link.ForeColor() = System.Drawing.Color.Black)then
e_link.ForeColor() = System.Drawing.Color.White
End If
End if
I have an error on this line: e_link.OnClick can you test this at all?
Thx, tammy
|
|
|
|
|
|
Ok I have switched out my hyperlink for a linkbutton as such:
Dim e_link As LinkButton = New LinkButton
MyTable.Rows(i + 1).Cells(k + 1).Controls.Add(e_link)
Now how do I actually test if the button was clicked? I am not sure how to handle events in vb.net as much as c#.
I have this line:
AddHandler e_link.Click, AddressOf e_link_Click
With this sub below:
Private Sub e_link_Click(ByVal sender As Object, ByVal e As EventArgs)
Response.Write("You clicked Me!")
End Sub
How to I actually call the event based on whether the link is clicked? Sorry if this sounds very simple - I am new to all of this.
I want to check that the cell(linkbutton) was clicked and if so perform my event.
Something like :
if e_link.click = true then . . . . .
|
|
|
|
|
Well, what you're doing with the event handler sounds good to me. I'm also a C# programmer starting to dabble in VB, so I'm not 100% sure. All I would suggest you add is a CommandName and CommandArgument . That way, when you get the handler method, you can pull out the CommandArgument which will have whatever pertinent information you wanted to be attached to that link. For instance, you could be the index of the cell in there.
Logifusion[^]
|
|
|
|
|
As far as I can tell there's no click event associated to the Hyperlink webcontrol. There is a ServerClick event for the HtmlAnchor control however, that will qualify for what you're trying to do.
Personally I'd try to work with the Attributes collection of the HyperLink or the Style collection of the table cell.
Hope this helps,
Patt
|
|
|
|