Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
<div id="mydiv"  runat="server">
 <style type="text/css" media="all">


table.second
{
    margin: 0;
    padding: 0;
    position: relative;
    top: 5px;
    left: 70px;


}
</style>

Protected Function doPageLoad(ByVal sender As Object, _
                                 ByVal e As System.EventArgs _
                                ) As IMaCSRetVal

       If Page.IsPostBack = False Then
           BindGridview()
           For dp As Integer = 1 To 10
               ddlst_Scale_pointers.Items.Add(dp)
           Next
       End If



Protected Sub ddlst_Scale_pointers_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlst_Scale_pointers.SelectedIndexChanged
     Dim sb As New StringBuilder()
     sb.Append("<table width='400' class='second'  border='1px'>")
     sb.Append("<tr>")
     sb.Append("<td>Pointer No</td>")
     sb.Append("<td>Pointer Label</td>")
     sb.Append("<td>Pointer Color</td>")
     sb.Append("</tr>")
     For i As Integer = 1 To ddlst_Scale_pointers.SelectedItem.Value
         sb.Append("<tr>")
         sb.Append("<td>" & i & "</td>")
         sb.Append("<td><input id='txtlbl" & i & "'  type='text' /></td>")
         sb.Append("<td><input id='txtcolour" & i & "' class='color' type='text' /></td>")

         sb.Append("</tr> ")
     Next
     sb.Append("</table>")
     sb.Append("</center>")
     mydiv.InnerHtml = sb.ToString()

 End Sub.




how can i fetch the values fom above table into hidden feild so that i can strore them to database?

how can i store values to database from above table?
Posted
Updated 14-Feb-13 17:44pm
v4
Comments
CHill60 14-Feb-13 6:38am    
You've forgotten to add any explanation or a question
Asim Mahmood 14-Feb-13 7:18am    
Please add your question here.
ZurdoDev 14-Feb-13 8:46am    
What do you need help with?
Member 9410081 15-Feb-13 0:41am    
i have updaed the question can any1 help urgentlly

=>First assign the "ID" field to table.
=>Call javascript fucntion before saving data to database to insert table rows into hiddenfields.
=>Start from second row of table,find each control in row, insert value of this control into hiddenfield separated by special character.
=>Once one row is insert into hiddenfield again insert another special character which indicates starting of the another row.

thus all the values will be insert into one hiddenfiled ,it will also help you separate each row,each value from heddenfield to insert into database.
 
Share this answer
 
Comments
Member 9410081 15-Feb-13 4:50am    
Thanks

can you give the codes as i am not getting
JavaScript
function  FillHidn()
    {
     var tbl=document.getElementById('myTable');//ID of table which you have given.
     var hiddenField=document.getElementById('<%=myHidden.ClientID %>');//hiddenfield.
     var result='';
     if(tbl.rows.length>1)
     {
      for(var RowCnt=1;RowCnt1)
     {
      result=result.substring(1);
     }
     hiddenField.value=result;
     return true;
    }


<asp:HiddenField ID="myHidden" runat="server" />
<asp:Button ID="Button1" runat="server" Text="save" OnClientClick="return FillHidn();" OnClick="Button1_Click" />


C#
protected void Button1_Click(object sender, EventArgs e)
    {
        if (myHidden.Value.Length &gt; 0)
        {
             string[] RowArr=myHidden.Value.Split('^');
             foreach (string obj in RowArr)
             {
                 string[] Cntrls = obj.Split('~');
                 //You can use this code to insert the rows into databse.
                 //Cntrls[0] First Cloumn of the table
                 //Cntrls[1] Second Cloumn of the table
                 //Cntrls[2] Third Cloumn of the table
             }
        }
    }
 
Share this answer
 
Comments
Member 9410081 16-Feb-13 1:32am    
giving error in this place

if (myHidden.Value.Length > 0)

gt is not defined in current context

Actually i dnt have any button clk on wich the hidden feild shuld filled

but i have a table created dynamically as i cannot fill this data dynamically into database i am trying store in hidden field so that the data from hidden feild can be stored into database.
[no name] 17-Feb-13 23:55pm    
Did you add Hiddenfield in your page?
Member 9410081 18-Feb-13 5:16am    
yes

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900