Hi,
Please enlight me how to insert/update/delete records based on generated textbox/checkbox.
I used the following code to generate the textbox/checkbox:
<asp:Repeater ID="myRepeater" runat="server" >
<HeaderTemplate>
<table >
<thead><tr>
<th>Terminal Tab</th>
<th>Terminal Attributes</th>
<th>Values
</th></tr></thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("TabName") %></td>
<td><%# Eval("TagName") %></td>
<td><%# GenerateTag(Eval("Datatype"))%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
Below is the function of GenerateTag:
protected string GenerateTag(object objDataType)
{
String strTags = "";
switch (objDataType.ToString()) {
case "Char":
strTags = "<input id=tagText type=text />";
break;
case "Int":
strTags = "<input id=tagInt type=text />";
break;
case "Boolean":
strTags = "<input id=cbx type=checkbox />";
break;
default:
strTags = "<input id=strInput type=text />";
break;
}
return strTags;
}
I use the following SQL statement in myRepeater:
string strSQL = @"
Select T.ID
, T.TabID TabID
, Tab.Name TabName
, T.TagName
, T.AppID
, T.DataType
, T.MinLen
, T.MaxLen
, A.Name AppName
, T.Description
From TerminalAttrTag T
Left Join TerminalAttrApp A on T.AppID = A.ID
Left Join TerminalAttrTab Tab on T.TabID = Tab.ID
Where T.AppID = {0} or T.AppID = 1
Order by T.TabID, T.SeqNo
";
strSQL = String.Format(strSQL, AppID);
myRepeater.DataSource = bl.GetDataSet(ConnectionString, strSQL);
myRepeater.DataBind();
In screen, it shows:
Terminal Tab Terminal Attributes Values
Host Config Host Name (Textbox)
Host Config Host IP (Textbox)
Host Config Timeout (Textbox)
I can input below info:
Terminal Tab Terminal Attributes Values
Host Config Host Name Machine1
Host Config Host IP 10.1.1.2
Host Config Timeout 30
Now I want to be able to click "Add" button to input below record (2nd records).
Terminal Tab Terminal Attributes Values
Host Config Host Name Machine2
Host Config Host IP 10.2.2.2
Host Config Timeout 50
I am thinking to use DetailsView but in the end I give up due to the dynamic generated textbox.
1. Please enlight me how I can add code in 'Add' button to insert records. Or which part of code need to be fixed or rewrite? And please advise the suitable way to handle this.
2. After problem of add/delete/update records solved, please enlight me how to loop through the records. I need to save all records to database or xml files.
Thank you for your patient.