|
|
Dim id As Integer = Request.QueryString("ui")
Dim cmd2 As String = ("Select Specification from DefineSpecification where CategoryID=" + id.ToString())
Dim rdr2 As IDataReader = db.ExecuteReader(CommandType.Text, cmd2)
Dim conn As New SqlConnection
Dim cmd As New SqlCommand("Select Count(*) from DefineSpecification Where CategoryID=" + id.ToString(), conn)
conn.ConnectionString = ConfigurationManager.ConnectionStrings("See2Buy").ConnectionString
conn.Open()
Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar())
While rdr2.Read
Dim lbl = New Label()
lbl.Width = "140"
lbl.Text = rdr2.Item("Specification")
Panel4.Controls.Add(lbl)
For counter2 As Integer = 1 To count
Dim txt = New TextBox()
txt.Width = "140"
txt.ID = "TextBoxID" + counter2.ToString
Panel4.Controls.Add(txt)
Dim txt1 As TextBox = CType(Panel4.FindControl("TextBoxID" + counter2.ToString()), TextBox)
Dim txt2 = CStr(txt1.Text)
Dim cmd3 As String = "Insert into Specification(SpecificationHeading,SpecificationDescription)Values('" + lbl.Text + "','" + txt2 + "')"
Dim dbcmd As DbCommand = db.GetSqlStringCommand(cmd3)
db.ExecuteNonQuery(dbcmd)
Next
End While
Error : Multiple controls with the same ID 'TextBoxID1' were found. FindControl requires that controls have unique IDs.
|
|
|
|
|
KhandelwalA wrote:
Error : Multiple controls with the same ID 'TextBoxID1' were found. FindControl requires that controls have unique IDs.
KhandelwalA wrote: For counter2 As Integer = 1 To count
Dim txt = New TextBox()
txt.Width = "140"
txt.ID = "TextBoxID" + counter2.ToString
Panel4.Controls.Add(txt)
Dim txt1 As TextBox = CType(Panel4.FindControl("TextBoxID" + counter2.ToString()), TextBox)
Dim txt2 = CStr(txt1.Text)
Dim cmd3 As String = "Insert into Specification(SpecificationHeading,SpecificationDescription)Values('" + lbl.Text + "','" + txt2 + "')"
Dim dbcmd As DbCommand = db.GetSqlStringCommand(cmd3)
db.ExecuteNonQuery(dbcmd)
Next
Check your code. You error clearly saying that, The ID which is generated for Texbox is not unique. Means Same Textbox ID generating multiple time.
|
|
|
|
|
KhandelwalA wrote: txt.ID = "TextBoxID" + counter2.ToString
As i told you in previous post dont use counter2. Instead create a new counter(c1) and increament it in your for loop.
txt.ID = "TextBoxID" + c1.ToString
himanshu
|
|
|
|
|
I did that but still getting the same error
|
|
|
|
|
KhandelwalA wrote: I did that
But in the code you have posted above,i cannot find where you have done that.
himanshu
|
|
|
|
|
i want to update a record in a gridview. its datatype is numeric how i can update that value?
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
cmd.CommandText = "UPDATE CouponTransaction SET CouponTypeID=@coupon_id, TransactionDate=@date, TransactionTypeID=@transaction_type,Description=@description,CafeMenu=@menu,SerialStart=@start, SerialEnd=@end,Price=@price WHERE RecordID=@record_id";
cmd.Parameters.Add("@coupon_id", SqlDbType.TinyInt).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
cmd.Parameters.Add("@record_id", SqlDbType.TinyInt).Value = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]["record_id"]);
cmd.Connection = cnx ;
cnx.Open();
cmd.ExecuteNonQuery();
cnx.Close();
GridView1.EditIndex = -1;
bindGridView();
}
in this code SerialStart has numeric datatype
|
|
|
|
|
actually sir i am sorry
i want a link button in gridview column and after click on link button text of this link button should be change for that particular row.
thanks,
|
|
|
|
|
vikas shukla wrote: i want a link button in gridview column and after click on link button text of this link button should be change for that particular row.
Question does not make any sense, what do you mean by that ? What about your last post? Did you check my answer ?
What you are cross posting?
|
|
|
|
|
Hi in my web application i have <b>one chart using xml data i have bind the chart in my site</b>...,
now my question <b>if any one need the chart for them site..., they can access the chart using some scripts/link url </b>...,
like gadget concept...,
how to create like that script..., plz give me some ideas...,
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
plz tell me,how to compare zero value with image control url
|
|
|
|
|
nari0820 wrote: plz tell me,how to compare zero value with image control url
What do you mean by that? You Mean, want to compare Image Path blank or what ?
|
|
|
|
|
I am using the following code to export Data Grid to excel. It works fine, except that it misses the leading '0's in the first column. For example, I have data in first column like '0034566'. When it exports to excel, the data is shown as '34566'. I have tried many things but it's still not working. Please help.
Imports System.Data
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition", "attachment;filename=SearchDownload.xls")
Response.Charset = ""
Me.EnableViewState = False
GridView1.AllowPaging = False
Dim dtSupplier As DataTable = DirectCast(ViewState("dtSupplier"), DataTable)
GridView1.DataSource = dtSupplier
GridView1.DataBind()
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
Dim StyleAsText As String = "<style> .StyleAsText{ mso-number-format:\@;} </style>"
GridView1.RenderControl(htmlWrite)
'Response.Write(strStyle)
'Response.Write(stringWrite.ToString())
Response.Write(StyleAsText + stringWrite.ToString())
Response.End()
End Sub
Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
End Class
|
|
|
|
|
I think, it because of you are exporting that field as number format.
|
|
|
|
|
Ok I have changed my code. I think it should work, But it isn't. Any suggestions? Please check my code below.
Imports System.Data
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim style As String = "<style> .text { mso-number-format:\@; } </style> "
Response.ClearContent()
Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls")
Response.ContentType = "application/excel"
GridView1.AllowPaging = False
Dim sw As New StringWriter()
Dim htw As New HtmlTextWriter(sw)
GridView1.DataBind()
GridView1.RenderControl(htw)
'Style is added dynamically
Response.Write(style)
Response.Write(sw.ToString())
Response.End()
End Sub
Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(0).Attributes.Add("class", "text")
End If
End Sub
End Class
|
|
|
|
|
Hi,
CHeck the below code...
Response.Clear()<br />
Response.Charset = ""<br />
'set the response mime type for excel<br />
Response.ContentType = "application/vnd.ms-excel"<br />
Response.Charset = "iso-8859-1"<br />
'create a string writer<br />
Dim stringWrite As New System.IO.StringWriter<br />
'create an htmltextwriter which uses the stringwriter<br />
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)<br />
dg.DataSource = ds<br />
'bind the datagrid<br />
dg.DataBind()<br />
'tell the datagrid to render itself to our htmltextwriter<br />
dg.RenderControl(htmlWrite)<br />
Dim strStyle As String = "<style>.text { mso-number-format:\@; } </style>"<br />
Response.Write(strStyle + stringWrite.ToString)<br />
Response.AddHeader("Content-Disposition", "attachment")<br />
Response.End()<br />
<br />
<br />
<br />
<br />
Protected Sub dg_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles dg.RowDataBound<br />
If e.Row.RowType = DataControlRowType.DataRow Then<br />
e.Row.Cells(1).Attributes.Add("class", "text")<br />
End If<br />
End Sub<br />
and just change the code in response.write line according to above...
Cheers
S Kumar
modified on Thursday, July 9, 2009 4:35 AM
|
|
|
|
|
Thanks a lot Kumar. It worked like a magic Thanks once again.
Hammad
|
|
|
|
|
Hi in my aspx page i have used ajax controls...,
in another page using request.forms i am getting the values of the prev page using post method...,
and inserting in to database...,
but the values are inserting 2 times...,
i dont y its happening...,
plz clear my doubt reg this....,
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
Member 3879881 wrote: i have used ajax controls...,
Which control are you using ?
Member 3879881 wrote: but the values are inserting 2 times...,
Show us the code? I guess it may be problem related with Postback !
|
|
|
|
|
Hi abhijit,
Thanks for ur reply...,
i have solved the probs...,
actually i given two times submit action thats y its happend...,
once again tks for ur reply
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
Member 3879881 wrote: actually i given two times submit action thats y its happend...,
|
|
|
|
|
hi sir,
i have a problem please solve this.
actually i have a gridview and in gridview i have column and column contain linkbutton now i want to add another linkbutton in that column in place of first linkbutton means first linkbutton will not display and this new linkbutton will display
|
|
|
|
|
vikas shukla wrote: actually i have a gridview and in gridview i have column and column contain linkbutton now i want to add another linkbutton in that column in place of first linkbutton means first linkbutton will not display and this new linkbutton will display
Then what is the use of First link button. or you want some visible true false kind of things !
|
|
|
|
|
Hi friends
I have a doc file in my project folder. I want the user to download the doc file for their reference. In that case, I used <a> tag
<a href="sample.doc" >download the sample doc</a>
The file opens well in IE in a write mode so that user can edit and save the file in his system memory. When I open the file using firefox, it opens in a read only mode so I m unable to modify/edit the file. I can modify it only after saving the file in my system memory...
I need to open the file in a write mode in firefox browser while open action without saving.
Could u help me how to solve this issue
Advance thanks.
G Nathan
|
|
|
|
|