
Hyuga
Avatar/Signature-
Posts
30 -
Joined
-
Last visited
Hyuga's Achievements
Newbie (1/14)
0
Reputation
-
Hello! I have a page with a Datagrid in it. This datagrid has a number of bound columns and one last template column that contains a linkbutton control. This LinkButton has to open a new page when the user clicks on it, but this page has to receive a parameter depending on some data contained in one of the bound columns. This is the definition of my Datagrid: <asp:DataGrid id="DatosTarea" Visible="False" ForeColor="Black" BackColor="White" BorderColor="Silver" Font-size="8pt" horizontalalign="left" cellpadding="4" AutoGenerateColumns="False" AllowSorting="True" OnSortCommand="Sort_Grid" runat="server"> <HeaderStyle font-bold="True" horizontalalign="Center" forecolor="White" backcolor="Navy"></HeaderStyle> <AlternatingItemStyle BorderColor="White" BackColor="White"></AlternatingItemStyle> <Columns> <asp:BoundColumn id="codigoTarea" HeaderText="Codigo de Tarea" DataField="CodigoTarea" SortExpression="CodigoTarea" /> <asp:BoundColumn HeaderText="Descripcion" DataField="DescripcionCorta" SortExpression="DescripcionCorta" /> <asp:BoundColumn HeaderText="Estado" DataField="DescripcionEstado" SortExpression="DescripcionEstado" /> <asp:BoundColumn HeaderText="Empleado" DataField="CodigoEmpleado" SortExpression="CodigoEmpleado" /> <asp:TemplateColumn HeaderText="Ver Detalles"> <ItemTemplate> <asp:linkButton id="accion" OnClick="CargarDetalle" runat="server">Detalle</asp:LinkButton> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> And the definition of the event handler: Sub CargarDetalle(sender As Object, e As System.EventArgs) Response.Write("<script>") Response.Write("window.open('TIdetalle.aspx?id=56','DetalleTareas','top=0,left=0,width=800,height=600,status=yes,resizable=yes,scrollbars=yes');") Response.Write("</" & "script>") End Sub Here, I have to change the value of the id field, and make it match the value contained in the boundcolumn codigoTarea. Do you know how can I achieve that?
-
Where do you assign the DataSource to "Me"?
-
Now I'm feeling like a complete stupid :o Thanks Kahlua ;)
-
Ok, I've found a solution, but I don't know why I have the problem I solved now. Searching through the net trying to find a solution, I reached this page: http://support.microsoft.com/default.aspx?scid=kb;en-us;314809 In one of the paragraphs, you can read that: So I have tried the solution to this, thinking that this will solve my problem. And it does. Below you can see what have I added to my code. In Page_Load() AddHandler CType(Page.FindControl("codigoEntidad"), DropDownList).SelectedIndexChanged, AddressOf CargarTareas This does the trick. But I don't know why the previous code is not binding correctly the event to my handler, my control is not dinamically created.
-
I'm recovering this thread because it's somehow related with my problem. I think I've readed the same article SteveoAtilla read before. But my problem is that I'm trying to display a Datagrid full of dropdownlists, and only one item(row) in it, and I don't know how to do it. I'm not binding nothing to the datagrid, in my test I'm only binding data to the DropDownLists, so I don't know if I can do what I want. It is possible to bind a Datagrid to an empty datasource? If it is, I can theh DataBind the datagrid and use the OnItemDataBound event to fill my dropdowns. Any idea?
-
It seems that in your ASP code you are looking for the button called BtnWrite, and you should look for the button testbutton. Your value, if the javascript works fine, should be placed in button1.value, and you have to access this control value from your ASP to recover it.
-
Add and <hr> using a control type LiteralControl.
-
Here I post the complete code of my page, to see if anybody can help me: <%@ Page Language="VB" EnableViewState="True" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OleDb" %> <script runat="server"> public empleado as String private strConexion As String = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & ConfigurationSettings.AppSettings("BDTI") private query As String Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim Conexion As OleDbConnection = New OleDbConnection(strConexion) Dim ConexionExiste As OleDbConnection = New OleDbConnection(strConexion) Dim i As Integer ' Buscamos el codigo de empleado, si se ha pasado y si existe en la base de datos If Not IsPostBack Then empleado = "10251651" If empleado <> "" Then Dim strSQLExiste as String = "SELECT CodigoEmpleado FROM Personas WHERE CodigoEmpleado LIKE '" + empleado + "'" Dim SQLExiste as New OleDbCommand(strSQLExiste, ConexionExiste) ConexionExiste.Open() Dim drExiste as OleDbDataReader = SQLExiste.ExecuteReader() If drExiste.hasRows Then usuarioApertura.Text = empleado 'Cargamos las entidades query = "SELECT CodigoEntidad FROM TCodigosEntidades" Dim da As New OleDbDataAdapter(query, Conexion) Dim ds As New DataSet da.Fill(ds, "CodigoEntidad") 'Asociamos los datos necesarios al DataGrid With codigoEntidad .selectedindex = 1 .DataTextField = "CodigoEntidad" .DataValueField = "CodigoEntidad" .DataSource = ds .DataBind() End With Else MuestraAlerta("Debe indicarse un Codigo de Empleado válido") End If ConexionExiste.Close() Else MuestraAlerta("Debe indicarse un Codigo de Empleado") End If Else usuarioApertura.text="kestapasando" End If End Sub Sub MuestraAlerta(MsgBoxText As String) Response.Write("<script language='JavaScript'>") Response.Write("alert('" & MsgBoxText & "');") Response.Write("<" & "/script>") Response.Write("<script>var win = window.self;win.opener=window.self;win.close();<" + "/script>") End Sub Sub CargarTareas(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim Conexion As OleDbConnection = New OleDbConnection(strConexion) Dim MsgBoxText As String = "comor" 'codigoEntidad.SelectedItem.Value Response.Write("<script language='JavaScript'>") Response.Write("alert('" & MsgBoxText & "');") Response.Write("<" & "/script>") Response.Write("<script>var win = window.self;win.opener=window.self;win.close();<" + "/script>") 'Cargamos tipos de tareas query = "SELECT CodigoTipoTarea, DescripcionTipoTarea FROM TCodigosTipoTarea WHERE CodigoEntidad LIKE '" + codigoEntidad.SelectedItem.Value + "'" Dim da As New OleDbDataAdapter(query, Conexion) Dim ds As New DataSet da.Fill(ds, "TipoTarea") 'Asociamos los datos necesarios al Dropdownlist With tipoTarea .DataTextField = "DescripcionTipoTarea" .DataValueField = "CodigoTipoTarea" .DataSource = ds .DataBind() End With End Sub </script> <html> <head> </head> <body> <form id="form1" runat="server"> <asp:Panel id="Panel1" runat="server" Width="100%"> <div><asp:Label id="labelUsuarioApertura" runat="server">Usuario de Apertura: </asp:Label><asp:Label id="usuarioApertura" runat="server"></asp:Label> </div> <div><asp:Label id="labelCodigoEntidad" runat="server">Entidad: </asp:Label> <asp: DropDownList id="codigoEntidad" runat="server" AutoPostBack="True" OnSelectedIndexChange="CargarTareas"></asp: DropDownList> </div> <div><asp:Label id="labelTipoTarea" runat="server">Tipo de Tarea: </asp:Label> <asp: DropDownList id="tipoTarea" runat="server"></asp: DropDownList> </div> <div><asp:Label id="labelTipoSubtarea" runat="server">Tipo de Subtarea: </asp:Label> <asp: DropDownList id="tipoSubtarea" runat="server"></asp: DropDownList> </div> </asp:Panel> </form> </body> </html> NOTE: Space included between asp and DropDownList to avoid the smilie conversion
-
Something strange was happening, when I try to load the page, the compiler tell me that the selectedindexchange event cannot be found. The dropdown is declared like this in the .aspx: <asp:DropDownList id="codigoEntidad" runat="server" AutoPostBack="True" OnSelectedIndexChange="CargarTareas"></asp:DropDownList> And in codebehind, I declare the control like this: Protected WithEvents codigoEntidad As System.Web.UI.WebControls.DropDownList And the event handler like this: Sub CargarTareas(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles codigoEntidad.SelectedIndexChange
-
Yesterday I have tried it, but when I try to use the "Handles", the compiler told me that it needs a WithEvents clause. I'll try again using codebehind (I'm writing my server-side code "inline")
-
¿Don't you have to add this to your datagrid definition? <asp:datagrid id=DataGrid1 runat="server" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" GridLines="Vertical" DataSource="<%# DsNegotiable1 %>" AutoGenerateColumns="False" DataMember="UnsecuredDebts" OnUpdateCommand="DataGrid1_UpdateCommand"> And OnCancelCommand, etc, etc.....
-
Can you post the HTML code of your DataGrid, please? Maybe it will help.
-
-
Maybe you can use a hidden field (with runat="server") who stores the value. This hidden field then can be accessed from server side and from client side, I suppose.
-
And the HTML code, as promised: <form runat="server"> <div><asp:Label id="labelUsuarioApertura" runat="server">Usuario de Apertura: </asp:Label> <asp:Label id="usuarioApertura" runat="server"></asp:Label> </div> <div><asp:Label id="labelCodigoEntidad" runat="server">Entidad: </asp:Label> <DropDownList id="codigoEntidad" onSelectedIndexChange="CargarTareas" AutoPostBack="True" runat="server"></DropDownList> </div> </form> The Sub CargarTareas is never reached, the Request.Params("__EVENTTARGET") has the correct object who has fired the OnClick event but the sub is not reached. Any idea? NOTE: I have changed the asp:_ DropDownList for DropDownList because of the board smilie convertor, it has been translated to this when posted: <asp<img src="images/smilies/biggrin.gif" border="0" alt="" title="Big Grin" class="inlineimg" />ropDownList :rolleyes: