Child gridview update event - asp.net

I have problem regarding child gridview (gridview inside ListView), so far i solved the databind and the the Delete command , but i couldn't figure out the Edut Mode ( i click the image button) but the GV doesn't go to edit mode the codes are as follows: thanks in advance
Page mark-up:
EditItemTemplate
<asp:ImageButton ID="imgbUpdate" runat="server" CommandName="Update" Text="Update" ImageUrl="~/Images/save_icon_mono.gif" CausesValidation="true" ValidationGroup="vgrpSaveContact"/>
<asp:ImageButton ID="imgbCancel" runat="server" CommandName="Cancel" Text="Cancel" ImageUrl="~/Images/undo_icon_mono.gif" CausesValidation="false"/>
EditItemTemplate
<ItemTemplate>
<table>
<tr>
<td> <asp:ImageButton ID="imgbEdit" runat="server" CommandName="Edit" Text="Edit" ImageUrl="~/Images/edit_icon_mono.gif" />
</td>
<td> <asp:ImageButton ID="imgbDelete" runat="server" CommandName="Delete" Text="Delete" ImageUrl="~/Images/delete_icon_mono.gif" ToolTip="Delete"/>
</td>
</tr>
</table>
</ItemTemplate>
Code VB.NET
Protected Sub gvSorties_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
Dim connString As String = ConfigurationManager.ConnectionStrings("MoyensAeriensConnectionString").ConnectionString
Dim gvTemp As GridView = DirectCast(sender, GridView)
gvUniqueID = gvTemp.UniqueID
'Get the value
Dim strSortieID As String = DirectCast(gvTemp.Rows(e.RowIndex).FindControl("lblSortieID"), Label).Text
Using conn As New SqlConnection
conn.ConnectionString = connString
conn.Open()
Try
Dim strSQL As String = ""
Dim dsTemp As New SqlDataSource()
dsTemp.ConnectionString = connString
'Get the values stored in the text boxes
Dim strMissionNo As String = DirectCast(gvTemp.Rows(e.RowIndex).FindControl("txtMissionNo"), TextBox).Text
Dim strCaptain As String = DirectCast(gvTemp.Rows(e.RowIndex).FindControl("txtCaptain"), TextBox).Text
Dim strCrew As String = DirectCast(gvTemp.Rows(e.RowIndex).FindControl("txtCrew"), TextBox).Text
Dim strFuel As String = DirectCast(gvTemp.Rows(e.RowIndex).FindControl("txtFuel"), TextBox).Text
'Prepare the Update Command of the DataSource control
strSQL = "UPDATE Sortie set MissionNo = '" & strMissionNo & "'" & ",Captain = " & strCaptain & "" & ",Crew = '" & strCrew & "'" & ",Fuel = '" & strFuel & "'" & " WHERE SortieID = " & strSortieID
dsTemp.UpdateCommand = strSQL
dsTemp.Update()
'Reset Edit Index
gvEditIndex = -1
lvODV.DataBind()
conn.Close()
Catch
End Try
End Using
End Sub
Many thanks to every one

Related

How to add different controls according to a database field for a survey app?

I'm creating a survey system. The creator must be able to create a question a decide what kind of control will give the answer (RadioButtonList, TextBox, etc...)
I have a data table (SQL) which stores the question, and the type of desired answer (dbo.Questions):
ID (int - PK)
IdForm (int - FK to dbo.Forms)
Question (varchar)
TypeOfAnswer (int)
And there's another data table that stores the user answer (dbo.Answers)
ID (int - PK)
QuestionId (int - FK to dbo.Questions.ID)
Answer (varchar)
UserId (int - FK to dbo.Users.ID)
Date (datetime)
So, one example of questions will be:
ID Question TypeOfAnswer
-----------------------------------------------------
1 What color do you like the most? 1
2 Are you happy with your bike? 2
3 What's your favorite ice cream flavor? 3
So the question ID.1 should have a RadioButtonList that will display Blue, Yellow, Green as a label and store 1, 2 or 3 as the value, according to the user's selection.
Question ID.2 sholud be RadioButtonList with only two answers, Yes, No for label and 1,2 for stored values.
Question ID3. should be a TextBox.
I'm having a really big struggle when printing the control to the view (on ASP.Net forms).
So far, I've created a dataset, and according to each row, it should print the question's label, and the user control that will store the answer, this is my code so far:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Dim ptipo As Integer = 2
Dim tcontrol1 As Control
tcontrol1 = LoadControl("/WebUSerControl.ascx")
Dim dt As New DataTable()
Dim connection As New SqlConnection(enchufalo1)
connection.Open()
Dim sqlCmd As New SqlCommand("SELECT * FROM [BORRAR_CL_Preguntas] WHERE ([IdFormato] = #IdFormato)", connection)
Dim sqlDa As New SqlDataAdapter(sqlCmd)
sqlCmd.Parameters.AddWithValue("#IdFormato", Request.QueryString("iform"))
sqlDa.Fill(dt)
Dim ctipo As Integer
For Each Row As DataRow In dt.Rows
ctipo = Row("TypeOfAnswer")
If ctipo = 1 Then
Dim rbl As RadioButtonList = New RadioButtonList()
rbl.ID = "rbl_prg1"
rbl.Items.Add("1")
rbl.Items.Add("2")
rbl.Items.Add("3")
ph_print.Controls.Add(rbl)
lit_prg.Text += Row("Question")
lit_prg.Controls.Add(tcontrol1)
End If
Next
End Sub
Right now the ph_print placeholder is printing the radiobutton, but skipping the first question!! And I have not been able to add the question label nor HTML styling
Any help would be appreciated!
I came up with a solution for this issue...
Here's the front code:
<asp:Repeater ID="rpt_preguntas" runat="server" DataSourceID="DS01">
<ItemTemplate>
<div class="Col100">
<div class="Col60">
<%#Eval("Pregunta") %>
</div>
<div class="Col5"></div>
<div class="Col35">
<div runat="server" visible='<%# (Eval("Tipo").ToString() = "1") %>'>
<asp:RadioButtonList ID="resp_tipo1_rbl" runat="server" RepeatDirection="Horizontal" RepeatColumns="6" ValidationGroup="valrspX">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
<asp:ListItem Value="6">NS/NR</asp:ListItem>
</asp:RadioButtonList>
</div>
<div runat="server" visible='<%# (Eval("Tipo").ToString() = "2") %>'>
<asp:TextBox ID="tb_tipo2" runat="server"></asp:TextBox>
</div>
<div runat="server" visible='<%# (Eval("Tipo").ToString() = "3") %>'>
<asp:DropDownList ID="ddl_perros" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="A">Azul enfermo</asp:ListItem>
<asp:ListItem Value="B">Blanco nigga</asp:ListItem>
<asp:ListItem Value="C">Café popó</asp:ListItem>
<asp:ListItem Value="D">Dorado blin blin</asp:ListItem>
</asp:DropDownList>
</div>
</div>
</div>
<br /><br />
<asp:Label ID="pregid" runat="server" Text='<%#Eval("ID") %>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:Repeater>
And the back code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_enviar.Click
Try
Dim spregid As Integer
Dim spregrs As String
For Each elemento As RepeaterItem In rpt_preguntas.Items
Dim prg_id As Label = DirectCast(elemento.FindControl("pregid"), Label)
Dim stipo As Integer
Dim SqlCon0 As SqlConnection
Dim SqlCom0 As SqlCommand
Dim SqlDR0 As SqlDataReader
SqlCon0 = New SqlConnection(ConfigurationManager.ConnectionStrings("EnchufeUNICOC").ToString())
SqlCom0 = New SqlCommand("SELECT * FROM [dbo].[BORRAR_CL_Preguntas] WHERE([ID] = '" & prg_id.Text & "')", SqlCon0)
SqlCom0.CommandType = CommandType.Text
If SqlCon0.State = ConnectionState.Closed Then
SqlCon0.Open()
'Dim p0 As New SqlParameter("#cc", SqlDbType.VarChar)
'p0.Direction = ParameterDirection.Input
'p0.Value = num_cc
'SqlCom0.Parameters.Add(p0)
End If
SqlDR0 = SqlCom0.ExecuteReader()
While SqlDR0.Read()
stipo = SqlDR0("tipo")
End While
SqlDR0.Close()
SqlCon0.Close()
Dim respuesta As String
If stipo = 1 Then
Dim control_t1 As RadioButtonList = DirectCast(elemento.FindControl("resp_tipo1_rbl"), RadioButtonList)
respuesta = control_t1.SelectedValue
End If
If stipo = 2 Then
Dim control_t2 As TextBox = DirectCast(elemento.FindControl("tb_tipo2"), TextBox)
respuesta = control_t2.Text
End If
If stipo = 3 Then
Dim control_t3 As DropDownList = DirectCast(elemento.FindControl("ddl_perros"), DropDownList)
respuesta = control_t3.SelectedValue
End If
resultados.Text += "Pregunta ID: " & prg_id.Text & "<br/>Respuesta: " & respuesta & "<br/><br/>"
Next
Catch ex As Exception
resultados.Text = "La cagamos mano:<br/><br/>" & ex.ToString
End Try
End Sub
So it was solved by adding a conditional to the Repeater control in it's ItemTemplate!

Object reference Error when filling textbox with data from database

I am trying to fill a text box with an ID of O1IDText when the selected value of a drop down list is changed. I get an error "Object reference not set to an instance of an object".
Here is my code in ASP of the drop down list:
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" AutoPostBack="true" runat="server" DataSourceID="SqlDataSource2" AppendDataBoundItems="true" OnDataBinding="DropDownlist1_DataBinding1" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" DataTextField="FullName" DataValueField="FullName" SelectedValue='<%# Bind("Official1") %>'>
</asp:DropDownList>
</EditItemTemplate>
Below is the code of my Textbox wihtin ASP:
<EditItemTemplate>
<asp:TextBox ID="O1IDText" runat="server" Text='<%# Bind("O1ID") %>'></asp:TextBox>
</EditItemTemplate>
And Finally my code behind in VB:
Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim ddList As DropDownList = CType(sender, DropDownList)
RemoveHandler ddList.DataBinding, AddressOf DropDownlist1_DataBinding1
Dim O1IDText As TextBox = TryCast(FindControl("O1IDText"), TextBox)
Dim cmd As SqlCommand = con.CreateCommand()
cmd.CommandType = System.Data.CommandType.Text
cmd.CommandText = "Select ID from Official where [First Name] + ' ' + [Last Name]+ ' ' +[Email]+ ' ' +[Phone] = '" + ddList.SelectedValue + "'"
Dim dr As SqlDataReader
Try
con.Open()
dr = cmd.ExecuteReader()
dr.Read()
O1IDText.Text = dr("ID").ToString
Catch ex As Exception
con.Close()
End Try
The exception "Object reference not set to an instance of an object" happens during O1IDText.Text = dr("ID").ToString.
Assuming that the DropDownList and the TextBox are both in the same row or item, you can get the TextBox this way:
Dim O1DText As TextBox = CType(ddList.NamingContainer.FindControl("O1DText"), TextBox)

Select from the first dropdownlist box is supposed to populate second dropdownlist with related values. My code is not doing that. Any ideas?

This is supposed to be easy. I have done it successfully a ton of times.
I select an option from drodpwonlist1 and the second dropdownlist gets populated based on select fro dropdownlist1.
For some reason, the code below is not working.
Please have a look at simplified version of the code:
'//markup:
<div class="ui-widget">
<asp:DropDownList ID="ddlUsers" runat="server" placeholder="Select a user..." AppendDataBoundItems="True" Width="300px" OnSelectedIndexChanged="ddlUsers_SelectedIndexChanged">
<asp:ListItem Value=""></asp:ListItem>
</asp:DropDownList>
</div>
<br /><br />
<div class="ui-widget">
<asp:DropDownList ID="ddlDates" runat="server" Enabled = "false" placeholder="Select a date..." Width="300px">
<asp:ListItem Value=""></asp:ListItem>
</asp:DropDownList>
</div>
'//Code behind:
Public Sub PopulateUsers()
Dim cmd As New SqlCommand("select DISTINCT c.userid,c.userName from tblUsers c " & _
"Inner Join tblInstructors i on c.instructorId = i.instructorId " & _
"ORDER BY c.userName ASC", New SqlConnection(ConfigurationManager.ConnectionStrings("DBConnectionString").ConnectionString))
cmd.Connection.Open()
Dim ddlValues As SqlDataReader
ddlValues = cmd.ExecuteReader()
ddlUsers.DataSource = ddlValues
ddlUsers.DataValueField = "userId"
ddlUsers.DataTextField = "userName"
ddlUsers.DataBind()
cmd.Connection.Close()
cmd.Connection.Dispose()
End Sub
Protected Sub ddlUsers_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
ddlDates.Items.Clear()
ddlDates.Items.Add(New ListItem("--Select a date--", ""))
ddlDates.AppendDataBoundItems = True
Dim strConnString As [String] = ConfigurationManager _
.ConnectionStrings("DBConnectionString").ConnectionString
Dim strQuery As [String] = "select DISTINCT d.dateId, d.TrainingDates from tblTrainingDates d " & _
"Inner Join tblCourses c on d.dateid=c.dateid " & _
"WHERE c.userId = #userId ORDER BY d.TrainingDates ASC"
Dim con As New SqlConnection(strConnString)
Dim cmd As New SqlCommand()
cmd.Parameters.AddWithValue("#userId", _
ddlUsers.SelectedItem.Value)
cmd.CommandType = CommandType.Text
cmd.CommandText = strQuery
cmd.Connection = con
Try
con.Open()
ddlDates.DataSource = cmd.ExecuteReader()
ddlDates.DataTextField = "dateId"
ddlDates.DataValueField = "TrainingDates"
ddlDates.DataBind()
If ddlDates.Items.Count > 1 Then
ddlDates.Enabled = True
Else
ddlDates.Enabled = False
End If
Catch ex As Exception
Throw ex
Finally
con.Close()
con.Dispose()
End Try
End Sub
If there is a match between userid from first dropdownlist and second dropdownlist, enable second dropdownlist and populate related values.
The second dropdownlist is not getting enabled, neither are associated values getting populated.
Any ideas what I could be doing wrong?
The code is not working becouse you forget the AutoPostback=True
<asp:DropDownList ID="ddlUsers" runat="server" placeholder="Select a user..." AppendDataBoundItems="True" Width="300px" OnSelectedIndexChanged="ddlUsers_SelectedIndexChanged" AutoPostback="True">
<asp:ListItem Value=""></asp:ListItem>
</asp:DropDownList>
Wihtout that the event OnSelectedIndexChanged never will fire.

Access to a file upload in gridView footer

This is my part of code for the grid view
<asp:GridView ID="gridViewCourse"
runat="server"
AutoGenerateColumns="False"
onrowcancelingedit="gridViewCourse_RowCancelingEdit"
onrowdeleting="gridViewCourse_RowDeleting" onrowediting="gridViewCourse_RowEditing"
onrowupdating="gridViewCourse_RowUpdating"
onrowcommand="gridViewCourse_RowCommand"
datakeynames="CourseId"
ShowFooter="True">
.....
<asp:TemplateField HeaderText="Fichier">
<EditItemTemplate>
<asp:FileUpload ID="FileUploadFichier" CssClass="upload" runat="server" Text='<%#Eval("Fichier") %>'/>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblFichier" runat="server" Text='<%#Eval("Fichier") %>'/>
</ItemTemplate>
<FooterTemplate>
<asp:FileUpload ID="FileUploadFichier" CssClass="upload" runat="server" />
<asp:RequiredFieldValidator ID="rfvFichier" runat="server" ControlToValidate="FileUploadFichier" Text="*" ValidationGroup="validaiton"/>
</FooterTemplate>
....
This my method "onrowcommand="gridViewCourse_RowCommand""
Protected Sub gridViewCourse_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
If e.CommandName.Equals("AddNew") Then
Dim txtId As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrId"), TextBox)
Dim txtCours As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrCours"), TextBox)
Dim txtPrix As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrPrix"), TextBox)
Dim txtTutor As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrTuteur"), TextBox)
con.Open()
Dim cmd As New SqlCommand(((("insert into Courses(CourseID,CourseName,Price,Tutor) values('" + txtId.Text & "','") + txtCours.Text & "','") + txtPrix.Text & "','") + txtTutor.Text & "')", con)
Dim result As Integer = cmd.ExecuteNonQuery()
con.Close()
If result = 1 Then
BindCoursesDetails()
lblresult.ForeColor = Color.Green
lblresult.Text = " Details inserted successfully"
Else
lblresult.ForeColor = Color.Red
lblresult.Text = " Details not inserted"
End If
End If
Dim upload As FileUpload = DirectCast(gridViewCourse.FindControl("FileUploadFichier"), FileUpload)
upload.SaveAs((Server.MapPath(Request.ApplicationPath & "/CoursesFiles/" & Path.GetFileName(FileUpload1.PostedFile.FileName))))
End Sub
The problem is The cast to upload (As FileUpload) contain nothing after...
The others are good and effective...
How I can acces to the FileUpload1 and save it ?
Thanks Frank
You're using two fileupload controls with the same id, try different IDs
and replace this line
Dim upload As FileUpload = DirectCast(gridViewCourse.FindControl("FileUploadFichier"), FileUpload)
with this one
Dim upload As FileUpload = DirectCast(gridViewCourse.FooterRow.FindControl("FileUploadFichier"), FileUpload)
Protected Sub gridViewCourse_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
If e.CommandName.Equals("AddNew") Then
Dim txtId As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrId"), TextBox)
Dim txtCours As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrCours"), TextBox)
Dim txtPrix As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrPrix"), TextBox)
Dim txtTutor As TextBox = DirectCast(gridViewCourse.FooterRow.FindControl("txtftrTuteur"), TextBox)
Dim upload As FileUpload = DirectCast(gridViewCourse.FindControl("FileUploadFichier"), FileUpload)
upload.SaveAs((Server.MapPath(Request.ApplicationPath & "/CoursesFiles/" & Path.GetFileName(FileUpload1.PostedFile.FileName))))
con.Open()
Dim cmd As New SqlCommand(((("insert into Courses(CourseID,CourseName,Price,Tutor) values('" + txtId.Text & "','") + txtCours.Text & "','") + txtPrix.Text & "','") + txtTutor.Text & "')", con)
Dim result As Integer = cmd.ExecuteNonQuery()
con.Close()
If result = 1 Then
BindCoursesDetails()
lblresult.ForeColor = Color.Green
lblresult.Text = " Details inserted successfully"
Else
lblresult.ForeColor = Color.Red
lblresult.Text = " Details not inserted"
End If
End If
End Sub
I have to put the cast before BindCoursesDetails()

VB.net. how to do databind for the all dropdownlist in repeater

I have a dropdownlist in my repeater, the dropdownlist is databound by a datasource. Originally all the dropdownlist will have all the same item option. I try to do if one of the showing dropdownlist is selected one option, then in other dropdownlist this option will disapper.
here is the asp:
<asp:Repeater ID="UnitMatchRepeater" runat="server" DataSourceID="OldUnitsDataSource" >
<ItemTemplate>
<tr>
<td>
<asp:Label ID="OldUnitNumber" runat="server" Text='<%# Eval("Vehicle")%>' value='<%#Container.DataItem("LinkNumber") %>'></asp:Label>
</td>
<td> </td>
<td>
<asp:DropDownList ID="NewUnitsDropDownBox" runat="server" DataSourceID="NewUnitsDataSource" DataTextField="UnitNumber"
DataValueField="LinkNumber" OnDataBound="call_it" AutoPostBack="true" value='<%# Container.DataItem("LinkNumber")%>'></asp:DropDownList>
</td>
<br/>
</tr>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="OldUnitsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:minotaurSQLConnectionString %>">
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="NewUnitsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:minotaurSQLConnectionString %>"
SelectCommand="SELECT Minotaur.dbo.Units.LinkNumber AS LinkNumber, RTAFleet.dbo.vehfile.vehicle AS UnitNumber FROM RTAFleet.dbo.vehfile INNER JOIN Minotaur.dbo.Units ON RTAFleet.dbo.vehfile.link_number = Minotaur.dbo.Units.LinkNumber AND Minotaur.dbo.Units.AcquisitionOrderID = #AcquisitionOrderID AND Minotaur.dbo.Units.SnapShotID = 1 AND Minotaur.dbo.Units.OldLinkNumber IS NULL">
<SelectParameters>
<asp:QueryStringParameter Name="AcquisitionOrderID" QueryStringField="orderID"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
here is the code behind:
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim LinkNoArray As String() = Request.QueryString("linkNumber").Split(",")
Dim SqlStr As String = "SELECT Vehicle = CASE WHEN ISNUMERIC(RTAFleet.dbo.vehfile.vehicle) = 1 AND RTAFleet.dbo.vehfile.vehicle IS NOT NULL THEN RTAFleet.dbo.vehfile.vehicle ELSE RTAFleet.dbo.vehfile.veh_xref_num END, RTAFleet.dbo.vehfile.link_number AS LinkNumber FROM RTAFleet.dbo.vehfile INNER JOIN Minotaur.dbo.Units ON RTAFleet.dbo.vehfile.link_number = Minotaur.dbo.Units.LinkNumber AND Minotaur.dbo.Units.SnapShotID = 1 WHERE "
For Each Str As String In LinkNoArray
SqlStr = SqlStr & " Minotaur.dbo.Units.LinkNumber = " & Trim(Str) & " OR"
Next
If Not Page.IsPostBack Then
SqlStr = Left(SqlStr, (SqlStr.Length - 2))
OldUnitsDataSource.SelectCommand = SqlStr
UnitMatchRepeater.DataBind()
End If
End Sub
Private Sub UnitMatchRepeater_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles UnitMatchRepeater.ItemCreated
If Not e.Item.ItemType = ListItemType.Item And Not e.Item.ItemType = ListItemType.AlternatingItem Then
Exit Sub
End If
Dim NewUnitsDDB As DropDownList = e.Item.FindControl("NewUnitsDropDownBox")
AddHandler NewUnitsDDB.SelectedIndexChanged, AddressOf NewUnitsDDB_SelectedIndexChanged
End Sub
Protected Sub NewUnitsDDB_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim linkNo As String = CType(sender, DropDownList).SelectedValue
Dim sqlStr As String = "UPDATE dbo.Units SET OldLinkNumber = #oldLinkNum WHERE LinkNumber = #newLinkNum"
Dim con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("minotaurSQLConnectionString").ConnectionString)
Dim cmd As SqlCommand = New SqlCommand(sqlStr, con)
cmd.Parameters.Add("#oldLinkNum", SqlDbType.Int).Value = CType(sender, DropDownList).Attributes("value")
cmd.Parameters.Add("#newLinkNum", SqlDbType.Int).Value = CInt(linkNo)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
dlistdatabinding()
End Sub
Private Sub dlistdatabinding()
For Each rep As RepeaterItem In UnitMatchRepeater.Items
Dim list As DropDownList = rep.FindControl("NewUnitsDropDownBox")
list.DataBind()
Next
End Sub
Please help to find out how to make it works.
thanks
Put your drop down list data binding code in the ItemDataBound event of your repeater. This is the event that fires every time it creates a "row" in your repeater. From there you can find the individual drop down list in the item.
The added benefit to this is that as each item is data bound, you could potentially change the contents of the drop down list based on the data you are working with.

Resources