|
Hi All,
I have Data Grid on aspx page. One of the column in that grid is a Template Column. I have added a Drop down list in EditItemTemplate. If I add this in ItemTemplate I am able to bind the DropDownList in code behind by making a reference using the below code:
e.Item.Cells(4).FindControl("ddlCountry")
But when this control is present in EditItemTemplate I am not able to get the reference to the above control. Can anybody suggest me how to go ahead with this situation?
Thank you,
Krishnaraj
|
|
|
|
|
Hi,
You can use Onitemdatabound event of the datagrid to do this. What you need to do is in that event you just check for the edititemtype and then bind the dropdownlist.
Hope this will help you.
BTW This you better post in asp.net forum.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi Apurva,
Thank you for your kind response,
The code I metioned earlier is inside the Onitemdatabound and before binding I am checking the ‘ListItemType.EditItem’. I am getting problem when I try to get the reference to the control using the below code inside he event handler. Please check this below code
Dim cmb As New DropDownList
If e.Item.ItemType = ListItemType.EditItem Then
cmb = e.Item.Cells(4).FindControl("ddlCountry")
End If
In the above code ‘ddlCountry’ is the dropdown list control id. If I add this control in the Item Template instead of Edit item template I get reference to it.
Krishnaraj
|
|
|
|
|
Hi,
Directly use e.Item.FindControl("ddlCountry").
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi,
Thanks a Lot… its working now…
Regards,
Krishnaraj
|
|
|
|
|
always welcome..
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hi,
I just want to connect with an microsoft access database in a remote mechine.
At first i try to connect with a database in local mechine.
Dim Cn As OleDbConnection
Dim strConString As String
strConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\localhost\D:\News\News\bin\News.mdb"
Cn = New OleDbConnection(strConString)
Cn.Open()
i got an error : '\\localhost\D:\News\News\bin\News.mdb' is not a valid path.
Please help me.
Thanks
Thomas
|
|
|
|
|
thomas_joyee wrote: i got an error : '\\localhost\D:\News\News\bin\News.mdb' is not a valid path.
Yea, right.
So what have you done to attempt to solve this problem? Tell us so we can help you.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
Sir,
i tried following options.
strConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\127.0.0.1\D:\News\News\bin\News.mdb"
strConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\computername\D:\News\News\bin\News.mdb".
But these are not working.
Thanks for your reply
Thomas
|
|
|
|
|
You are first trying to connect to an MDB on your local machine right?
If so, the Data Source parameter is malformed for a local path. That's what the error message has told you already.
Try copying the path you specify into the address box of Windows Explorer and see what it tells you. Now modify it until it works and then you should be able to use that in your connect string.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
Hi,
with windows explorer i found this code will work.
strConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\127.0.0.1\D\News\News\bin\News.mdb"
Thanks for your valuable help.
Thomas
|
|
|
|
|
You are very welcome.
Another happy customer
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
Hi I am trying to place placeholder template within a datalist for some reason i am getting this error that says object reference not set to instance of an object the
aspx page is:
<asp:datalist id="dlScHead" runat="server" showfooter="False" showheader="False" cellspacing="0"
="" cellpadding="0" width="100%">
<itemtemplate>
<%# ctype(DataBinder.Eval(Container.DataItem,"ScoreCardID"),string) %>
<%# ctype(DataBinder.Eval(Container.DataItem,"scorecarddesc"),string) %>
<%# ctype(DataBinder.Eval(Container.DataItem,"BusinessGoal"),string) %>
|
<asp:datalist id="dlScChart" width="100%" datasource="<%# (GetRecords(Cstr(DataBinder.Eval(Container.DataItem, "ScoreCardId")))) %>" runat="server">
<itemstyle verticalalign="Top" backcolor="#EEEEEE">
<itemtemplate>
<asp:placeholder id="Placeholder1" runat="server">
|
<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter1").tostring()) %>
<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter2").tostring()) %>
<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter3").tostring()) %>
<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter4").tostring()) %>
|
================================================
and code behind
--------------------
in page load event i am doing
dlScHead.DataSource = GetRecords(Nothing)
dlScHead.DataBind()
and in function getRecords i am doing
Function GetRecords(ByVal scID As String) As SqlDataReader
Dim bizProgName As String = Request.QueryString("bizProgId")
Dim CommandText As String
Try
objConn = New SqlConnection(dbPath)
objConn.Open()
If scID = Nothing Then
Dim da As New SqlDataAdapter
da.SelectCommand = New SqlCommand
da.SelectCommand.Connection = objConn
da.SelectCommand.CommandText = "select scorecardId,bizProgId,scorecarddesc,businessgoal,strategy,quarter1,quarter2,quarter3,quarter4 from textData where bizProgID='" & Request.QueryString("bizProgId") & "'"
dr = da.SelectCommand.ExecuteReader(CommandBehavior.CloseConnection)
If dr.HasRows Then
'lblError.Text = ""
Else
'lblError.Text = "No records returned"
End If
GetRecords = dr
Else
cmd = New SqlCommand("select distinct measure_id from measuredata where scoreCardId = '" & scID & "'", objConn)
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim dtid As New DataTable("measureid")
da.fill(dtid)
'select all columns with id
Dim cmd1 As SqlCommand = New SqlCommand("select * from measuredata where scorecardid = '" & scID & "'", objConn)
Dim da1 As SqlDataAdapter = New SqlDataAdapter(cmd1)
Dim dt As New DataTable("measuresource")
da1.Fill(dt)
Dim datarow As DataRow
For Each datarow In dtid.Rows
Dim chart As New DataGrid
Dim myview As New DataView(dt)
' dim chart as new mycos.mycoschartweb
myview.RowFilter = String.Format("measure_id='{0}'", datarow.Item("measure_id"))
chart.DataSource = myview
chart.DataBind()
Dim i As Integer
For i = 0 To dlScChart.Items.Count - 1
dlScChart.Items(i).FindControl("placeholder1").Controls.Add(chart)
Next
Next datarow
' GetRecords = PlaceHolder1.FindControl("placeholder1")
End If
Catch ex As Exception
Response.Write("error on child-- here" + ex.ToString + " ")
Finally
End Try
End Function
i am getting error in
dlScChart.Items(i).FindControl("placeholder1").Controls.Add(chart)
please help thanks
|
|
|
|
|
I don't see the placeholder in your aspx code.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
uglyeyes wrote: For i = 0 To dlScChart.Items.Count - 1
dlScChart.Items(i).FindControl("placeholder1").Controls.Add(chart)
Next
Where is dlScChart defined and created?
You also may get better results if you posted this question in the right forum.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
Just an Idea as its not letting me post asp scripts as a whole
----------
datalist id="dlScHead"
ItemTemplate
.. ctype(DataBinder.Eval(Container.DataItem,"ScoreCardID"),string).. |
datalist ID="dlScChart" DataSource=..(GetRecords(Cstr(DataBinder.Eval(Container.DataItem, "ScoreCardId")))) ..
ItemTemplate
<asp:placeholder id="Placeholder1" runat="server">
/ItemTemplate
<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter1").tostring()) %>
<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter2").tostring()) %>
<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter3").tostring()) %>
<%# Server.htmlDecode(DataBinder.Eval(Container.DataItem,"Quarter4").tostring()) %>
|
/ItemTemplate
/asp:datalist
|
|
|
|
|
No it means nothing to me.
Like I said - post your question in the right forum (hint: try ASP.NET or Web Development ). You may get an answer there.
This forum is for VB/VB.NET questions.
Also a hint for pasting code..... check the checkbox named Ignore HTML tags in this message (good for code snippets) .
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
|
|
|
|
|
Hi all,
im new to vb.net and im trying to lure myself to it.
im trying to create a simple logon program using MS ACCESS as my database.
can somebody help me out on how to validate a log-in transaction.
i'am totally lost on this.
tnx...
-::maximus::-
|
|
|
|
|
Like 95% of people, you're jumping in too deep. If you're new to VB, learn he langue first, then worry about databases.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How can I create a batch file using vb.net and then execute the batch file by clicking a button on the form. After the batch file has finished executing, it will be deleted.
Thank you for any reply
|
|
|
|
|
A batch file is just text. Just create a text file, called something.bat. Process.Start will run it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
or
You can simply do it using shell function without creating a batch file.
Shell("CommandLine1 & CommandLine2", AppWinStyle.Hide)
Regards,
Chatura Dilan
|
|
|
|
|
When I run my application, and type letter “a” (letters), I need to type a Unicode character(s) instead of letter “a”(in word pad or any word processing application). I have seen applications like that, but I have no idea how to do that
Do you have any ideas?
Thank You,
&
Regards,
Chatura Dilan
|
|
|
|
|
Wonder if any of you guys could point me in the right direction? Everywhere I've searched on Google always shows me how to do this with a datagrid - but not a form - and it just doesn't seem to want to work how I want it work.
I've created a form which correctly displays all my fields in a recordset. I can scroll through them, add new records, delete records, etc. etc. and everything is fine.
I now want to add a Search field to the form so that when the user enters a search string, it automatically searches through the dataset for EITHER the CompanyName OR the CompanyID - and refreshes the display to display the appropriate search result (ie. populates the currently open form with the appropriate record).
-- modified at 18:21 Wednesday 31st May, 2006
I partly figured it out - but can't get it to work with an OR part of the SQL. Any advice would be appreciated. The CompanyID is an Autonumber field.
Dim strSearch As String = "SELECT * FROM tblCustomersParent WHERE CustomerName Like '%" & txtSearchString.Text & "%'"<br />
<br />
Me.OleDbSelectCommand1.CommandText = strSearch<br />
Me.LoadDataSet()
|
|
|
|
|
Are you trying to do a like on the auto number field?
"SELECT * FROM tblCustomersParent WHERE CustomerName Like '%" & txtSearchString.Text & "%' or CompanyID = " & txtCompanyName
You should really look at using parameterized queries as well.
Mike Lasseter
|
|
|
|