|
below is my gridview setting.. i put the gridview in a div.
I tried to create new gridview outside the div also not able to retrieve.
and i tried to retrieve to formview also cannot.
Pls help me......
Thank you very much.......
<asp:content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="Server" xmlns:asp="#unknown">
<asp:gridview id="gvSearch" runat="server" allowsorting="True" autogeneratecolumns="False" backcolor="#DEBA84" bordercolor="#DEBA84" borderstyle="None" borderwidth="1px">
CellPadding="3" CellSpacing="2" Font-Size="Small">
<footerstyle backcolor="#F7DFB5" forecolor="#8C4510">
<pagersettings mode="NumericFirstLast">
<rowstyle backcolor="#FFF7E7" forecolor="#8C4510">
<selectedrowstyle backcolor="#804040" font-bold="True" forecolor="White">
<headerstyle backcolor="#A55129" font-bold="True" forecolor="White">
<asp:content>
|
|
|
|
|
Eunice (VB junior) wrote: autogeneratecolumns="False"
OK - so where is the code to define the columns ? Did you try a style for the empty grid ? Did you look at the html to see if the div is visible ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
The div is visible.I didn't try the empty grid as I'm not too sure how to do it. sorry coz I'm still new to asp.net.
I declare the columns at InitMyTable...
Sub InitMyTable()
myTable = New DataTable("Search")
Dim EmpNo As DataColumn = New DataColumn("EmpNo")
EmpNo.DataType = System.Type.GetType("System.Int32")
myTable.Columns.Add(EmpNo)
Dim EmpName As DataColumn = New DataColumn("EmpName")
EmpName.DataType = System.Type.GetType("System.String")
myTable.Columns.Add(EmpName)
Dim ICNo As DataColumn = New DataColumn("ICNo")
ICNo.DataType = System.Type.GetType("System.String")
myTable.Columns.Add(ICNo)
Dim CostCenter As DataColumn = New DataColumn("CostCenter")
CostCenter.DataType = System.Type.GetType("System.String")
myTable.Columns.Add(CostCenter)
Dim Division As DataColumn = New DataColumn("Division")
Division.DataType = System.Type.GetType("System.String")
myTable.Columns.Add(Division)
Dim ds As New DataSet
ds = New DataSet
ds.Tables.Add(myTable)
Me.gvSearch.DataSource = myTable
Me.gvSearch.DataBind()
End Sub
i found one vb code but it's in window application (not asp.net)...
it has this extra line :- datagrid1.Update() after the datareader looping...
But i'm not too sure how to convert it into asp.net
in asp.net, it only has gvSearch.UpdateRow(). But it cannot recognized as well.
Please help.... Sorry to trouble you....
Thanks in advanced....
|
|
|
|
|
Remove the line that says 'autogeneratecolumns="false". Set it to true. I am sure your issue is that you are not defining any columns.
And, you need to buy a book on ASP.NET and work through it, unless you're just coding for fun. If someone is paying you, you should be ashamed. If you want to get paid at some point, buy a book and work through these basics.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi Christian Graus,
Thank you so much of ur help.. It works brilliant by now...
thanks for ur advice as well..
|
|
|
|
|
OK - the lesson is to turn autogeneration on, or to actually define some columns in the ASPX. Your code behind code was obviously not doing that, and it's messy anyhow, the aspx is the right place to define the columns of the grid.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks,I understand now... Chris,you are a good 'teacher'.
|
|
|
|
|
Hi! Is there an example on how I can hover the mouse over listbox item (image names) and show the image? Thanks!....Also my images are from Database...
|
|
|
|
|
Try this[^]
Be careful, there is no Undo Button(Ctrl+Z) in life.
|
|
|
|
|
Hi folks,
I have add a dropdownlist into my datagridview. This dropdown list consists two unbound value (item1= 'YES' and item2= 'NO')
How can I update my datagridview data by using update button. Any idea?
error message is:
"DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items"
|
|
|
|
|
Try to create a list of items, hard coded ( just a List<string> will do ), and then bind to that.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks for your reply..
I have added the following code and no change occured:
<asp:TemplateField HeaderText="EAN" SortExpression="EAN">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataTextField="EAN" DataValueField="EAN" >
<asp:ListItem Text="YES" Value="YES" />
<asp:ListItem Text="NO" Value="NO" />
</asp:DropDownList>
</EditItemTemplate>
|
|
|
|
|
Hello,
Thank you for your reply. I have added the following code but nothing changed:
<asp:TemplateField HeaderText="EAN" SortExpression="EAN">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataTextField="EAN" DataValueField="EAN" >
<asp:ListItem Text="YES" Value="YES" />
<asp:ListItem Text="NO" Value="NO" />
</asp:DropDownList>
</EditItemTemplate>
|
|
|
|
|
Hello,
I have declared an image control. I'm trying to display a picture from my db using linq.
The code:
protected void Button1_Click(object sender, EventArgs e)
{
DataClassesDataContext db = new DataClassesDataContext();
test1 x2 = db.test1s.First(p => p.descriere.StartsWith("xxx"));
byte[] img = (x2.img);
MemoryStream ms = new MemoryStream(img);
System.Drawing.Image Image1 = System.Drawing.Image.FromStream(ms);
}
where test1 is a table with 3 fields- id-int/descriere char/img image. Do i need more code for the picture to show? or what is the problem?
|
|
|
|
|
You're using LINQ, but you don't know how a website displays images ?
You need to provide a URL to an image, or a URL to a page that streams back these bytes. I don't see any code here that even attempts to display your image.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
can you, please, show me -in code- how can i display the picture from the byte[]: img?
test1 x2 = db.test1s.First(p => p.descriere.StartsWith("xxx"));
byte[] img = (x2.img);
|
|
|
|
|
|
the code so far is:
protected void Button1_Click(object sender, EventArgs e)
{
DataClassesDataContext db = new DataClassesDataContext();
test1 x2 = db.test1s.First(p => p.descriere.StartsWith(" Firma bazata pe intuitia cumparatorulu"));
byte[] img = (x2.img);
MemoryStream ms = new MemoryStream(img);
System.Drawing.Image Image1 = System.Drawing.Image.FromStream(ms);
MemoryStream stream = new MemoryStream;
Image1.Save(stream,ImageFormat.Jpeg);
Bitmap b = new Bitmap(Image1.Width, Image1.Height);
Graphics g = new Graphics.FromImage(b);
}
my error: 'System.Drawing.Graphics.FromImage(System.Drawing.Image)' is a 'method' but is used like a 'type'.
Can someone tell me what why or show me the right code?
|
|
|
|
|
when i try & get my "objdscolleaguedetails could no tfind a non-generic method 'updcolleaguedetails' that has parametera: strconn, colleaguename, mobile, extension, colleagueid.
I've set the gridview's datakeynames to colleagueid,colleaguename,mobile,extension.
I've set my control parameters to update the three fields.
I just cannot figure out why it does not work.
<pre>Web methods
<webservice(namespace:> _
<webservicebinding(conformsto:> _
<global.microsoft.vi></global.microsoft.vi> sualBasic.CompilerServices.DesignerGenerated()> _
Public Class WAB_DataAccessWS
Inherits System.Web.Services.WebService
<webmethod()> _
Public Function GenericQuery(ByVal strConn As String, ByVal strQuery As String) As DataSet
Return WAB_DataAccess.GenericQuery(strConn, strQuery)
End Function
'Select method
<webmethod()> _
Public Function selColleagueDetails(ByVal strConn As String, ByVal intDepartmentID As Integer) As DataSet
Return WAB_DataAccess.selaColleagueDetails(strConn, intDepartmentID)
End Function
'Update method
<webmethod()> _
Public Function updColleagueDetails(ByVal strConn As String, ByVal intColleagueID As Integer, ByVal strColleagueName AS String, ByVal strMobile As String, ByVal strExtension As String) As Integer
Return WAB_DataAccess.UpdaColleagueDetails(strConn, intColleagueID, strColleagueName, strMobile,strExtension)
End Function
End Class
Class
Public Class WAB_DataAccess
Inherits DataAccessBase_v2
' this will be deprecated
Public Shared Function GenericQuery(ByVal strConn As String, ByVal strQuery As String) As DataSet
Return ExecuteQuery_ds(strConn, strQuery)
End Function
'select method called from the webservice
Public Shared Function selaColleagueDetails(ByVal strConn As String, ByVal intDepartmentID As Integer) As DataSet
Return ExecuteQuery_ds(strConn, "exec p_ColleagueDetails " & CStr(intDepartmentID))
End Function
Public Shared Function UpdaColleagueDetails(ByVal strConn As String, ByVal intColleagueID As Integer, ByVal strColleagueName AS String, ByVal strMobile As String, ByVal strExtension As String) As Integer
Dim conn As SqlConnection = New SqlConnection(strConn)
Dim cmd As SqlCommand = New SqlCommand("exec p_UpdateColleaguesDetails '" & intColleagueID & "', '" & strColleagueName & "', " & strMobile & ", '" & strExtension & "'", conn)
Dim result As Integer = 0
conn.Open()
result = cmd.ExecuteNonQuery()
conn.Close()
Return result
End Function
End Class
]]>
]]>
<asp:content id="topContent" contentplaceholderid="topContent" runat="Server" xmlns:asp="#unknown">
<asp:hiddenfield id="hdnMainConnStr" runat="server">
<asp:hiddenfield id="hdnQueryDepartmentDetails" runat="server">
<asp:hiddenfield id="hdnQueryColleagueDetails" runat="server">
<%--use this hiddenfield to update the values of the datagrid with new colleague details--%>
<asp:hiddenfield id="hdnUpdateColleagues" runat="server">
<%--use this hiddenfield to update the values of the datagrid with new colleague details--%>
<asp:hiddenfield id="hdnParamDeleteColleagues" runat="server">
<asp:hiddenfield id="hdnQueryAddColleague" runat="server">
<asp:label id="lblMsg" runat="server" cssclass="" enableviewstate="false">Please Select Your Department |
<asp:dropdownlist id="ddlDepartment" runat="server" cssclass="" datasourceid="objDepartmentDetails" datatextfield="DepartmentName" datavaluefield="DepartmentID" autopostback="true">
<asp:objectdatasource id="objDepartmentDetails" runat="server" selectmethod="GenericQuery" typename="WAB_DataAccessWS.WAB_DataAccessWS">
<selectparameters>
<asp:controlparameter controlid="hdnMainConnStr" name="strConn" propertyname="Value" type="String">
<asp:parameter defaultvalue="exec p_DepartmentDetails" name="strQuery" type="String">
|
Rows per page:
<asp:textbox id="txtRowsPerPage" runat="server" cssclass="" autopostback="true" columns="4" maxlength="4" tabindex="5">
(<%=intMinRows%>-<%=intMaxRows%>)
|
<asp:gridview id="gvwColleagueDetails" runat="server" emptydatatext="No colleague records were found.">
datasourceid="objdsColleagueDetails" cellpadding="4" gridlines="None"
width="100%" allowsorting="True" allowpaging="True"
autogeneratecolumns="False" ForeColor="#333333" ShowFooter="True" DataKeyNames="ColleagueID,ColleagueName,Mobile,Extension">
<pagersettings position="Top">
<pagerstyle horizontalalign="Center" backcolor="#284775" forecolor="White">
<footerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<headerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<editrowstyle backcolor="#999999">
<alternatingrowstyle backcolor="White" forecolor="#284775">
<selectedrowstyle forecolor="#CCFF99" font-bold="True">
BackColor="#009999">
<rowstyle forecolor="#003399" backcolor="White">
<columns> <asp:commandfield showeditbutton="True" showdeletebutton="True" deletetext="Remove" headertext="Add Remove Collegaue">
<asp:boundfield headertext="ColleagueID" readonly="True" datafield="ColleagueID" sortexpression="ColleagueID">
<asp:templatefield headertext="ColleagueName" sortexpression="ColleagueName">
<edititemtemplate>
<asp:textbox id="txtColleagueName" runat="server" text="<%# Bind(" colleaguename")="" %>"="">
<itemtemplate>
<asp:label id="lblColleagueName" runat="server" text="<%# Eval(" colleaguename")="" %>"="">
<asp:templatefield headertext="Mobile" sortexpression="Mobile">
<edititemtemplate>
<asp:textbox id="txtMobile" runat="server" text="<%# Bind(" mobile")="" %>"="">
<itemtemplate>
<asp:label id="lblMobile" runat="server" text="<%# Eval(" mobile")="" %>"="">
<asp:templatefield headertext="Extension" sortexpression="Extension">
<edititemtemplate>
<asp:textbox id="txtExtension" runat="server" text="<%# Bind(" extension")="" %>"="">
<itemtemplate>
<asp:label id="lblExtension" runat="server" text="<%# Eval(" extension")="" %>"="">
<%--<asp:objectdatasource id="objdsColleagueDetails" runat="server" selectmethod="GenericQuery" updatemethod="hdnUpdateColleagues" typename="WAB_DataAccessWS.WAB_DataAccessWS">--%>
<asp:objectdatasource id="objdsColleagueDetails" runat="server" typename="WAB_DataAccessWS.WAB_DataAccessWS" selectmethod="selColleagueDetails" updatemethod="updColleagueDetails">
<selectparameters>
<asp:controlparameter controlid="hdnMainConnStr" name="strConn" propertyname="Value" type="String">
<asp:controlparameter controlid="ddlDepartment" name="intDepartmentID" propertyname="SelectedValue" type="Int32">
<updateparameters>
<asp:controlparameter controlid="hdnMainConnStr" defaultvalue="" name="strConn" propertyname="Value" type="String">
<asp:parameter name="ColleagueName" type="String">
<asp:parameter name="Mobile" type="String">
<asp:parameter name="Extension" type="String">
|
<asp:label id="Label1" runat="server" cssclass="" enableviewstate="false">Add Colleague Details
|
<asp:dropdownlist id="ddlAddColleague" runat="server" cssclass="" datasourceid="objdsAddColleague" datavaluefield="ColleagueName" autopostback="true">
<asp:objectdatasource id="objdsAddColleague" runat="server" selectmethod="GenericQuery" typename="WAB_DataAccessWS.WAB_DataAccessWS">
<selectparameters>
<asp:controlparameter controlid="hdnMainConnStr" name="strConn" propertyname="Value" type="String">
<asp:parameter defaultvalue="exec p_AddColleague" name="strQuery" type="String">
| <asp:button id="btnAdd" cssclass="" runat="server" text="Add Colleague" tooltip="Add Colleague" onclientclick="return confirmAction('Are you sure you want to Add Colleague"> |
thanks for your help
|
|
|
|
|
when i try & get my "objdscolleaguedetails could no tfind a non-generic method 'updcolleaguedetails' that has parametera: strconn, colleaguename, mobile, extension, colleagueid.
I've set the gridview's datakeynames to colleagueid,colleaguename,mobile,extension.
I've set my control parameters to update the three fields.
I just cannot figure out why it does not work.
Web methods
<webservice(namespace:> _
<webservicebinding(conformsto:> _
<global.microsoft.visualbasic.compilerservices.designergenerated()> _
Public Class WAB_DataAccessWS
Inherits System.Web.Services.WebService
<webmethod()> _
Public Function GenericQuery(ByVal strConn As String, ByVal strQuery As String) As DataSet
Return WAB_DataAccess.GenericQuery(strConn, strQuery)
End Function
'Select method
<webmethod()> _
Public Function selColleagueDetails(ByVal strConn As String, ByVal intDepartmentID As Integer) As DataSet
Return WAB_DataAccess.selaColleagueDetails(strConn, intDepartmentID)
End Function
'Update method
<webmethod()> _
Public Function updColleagueDetails(ByVal strConn As String, ByVal intColleagueID As Integer, ByVal strColleagueName AS String, ByVal strMobile As String, ByVal strExtension As String) As Integer
Return WAB_DataAccess.UpdaColleagueDetails(strConn, intColleagueID, strColleagueName, strMobile,strExtension)
End Function
End Class
Class
Public Class WAB_DataAccess
Inherits DataAccessBase_v2
' this will be deprecated
Public Shared Function GenericQuery(ByVal strConn As String, ByVal strQuery As String) As DataSet
Return ExecuteQuery_ds(strConn, strQuery)
End Function
'select method called from the webservice
Public Shared Function selaColleagueDetails(ByVal strConn As String, ByVal intDepartmentID As Integer) As DataSet
Return ExecuteQuery_ds(strConn, "exec p_ColleagueDetails " & CStr(intDepartmentID))
End Function
Public Shared Function UpdaColleagueDetails(ByVal strConn As String, ByVal intColleagueID As Integer, ByVal strColleagueName AS String, ByVal strMobile As String, ByVal strExtension As String) As Integer
Dim conn As SqlConnection = New SqlConnection(strConn)
Dim cmd As SqlCommand = New SqlCommand("exec p_UpdateColleaguesDetails '" & intColleagueID & "', '" & strColleagueName & "', " & strMobile & ", '" & strExtension & "'", conn)
Dim result As Integer = 0
conn.Open()
result = cmd.ExecuteNonQuery()
conn.Close()
Return result
End Function
End Class
]]>
]]>
<asp:content id="topContent" contentplaceholderid="topContent" runat="Server" xmlns:asp="#unknown">
<asp:hiddenfield id="hdnMainConnStr" runat="server">
<asp:hiddenfield id="hdnQueryDepartmentDetails" runat="server">
<asp:hiddenfield id="hdnQueryColleagueDetails" runat="server">
<%--use this hiddenfield to update the values of the datagrid with new colleague details--%>
<asp:hiddenfield id="hdnUpdateColleagues" runat="server">
<%--use this hiddenfield to update the values of the datagrid with new colleague details--%>
<asp:hiddenfield id="hdnParamDeleteColleagues" runat="server">
<asp:hiddenfield id="hdnQueryAddColleague" runat="server">
<asp:label id="lblMsg" runat="server" cssclass="" enableviewstate="false">Please Select Your Department |
<asp:dropdownlist id="ddlDepartment" runat="server" cssclass="" datasourceid="objDepartmentDetails" datatextfield="DepartmentName" datavaluefield="DepartmentID" autopostback="true">
<asp:objectdatasource id="objDepartmentDetails" runat="server" selectmethod="GenericQuery" typename="WAB_DataAccessWS.WAB_DataAccessWS">
<selectparameters>
<asp:controlparameter controlid="hdnMainConnStr" name="strConn" propertyname="Value" type="String">
<asp:parameter defaultvalue="exec p_DepartmentDetails" name="strQuery" type="String">
|
Rows per page:
<asp:textbox id="txtRowsPerPage" runat="server" cssclass="" autopostback="true" columns="4" maxlength="4" tabindex="5">
(<%=intMinRows%>-<%=intMaxRows%>)
|
<asp:gridview id="gvwColleagueDetails" runat="server" emptydatatext="No colleague records were found.">
datasourceid="objdsColleagueDetails" cellpadding="4" gridlines="None"
width="100%" allowsorting="True" allowpaging="True"
autogeneratecolumns="False" ForeColor="#333333" ShowFooter="True" DataKeyNames="ColleagueID,ColleagueName,Mobile,Extension">
<pagersettings position="Top">
<pagerstyle horizontalalign="Center" backcolor="#284775" forecolor="White">
<footerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<headerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<editrowstyle backcolor="#999999">
<alternatingrowstyle backcolor="White" forecolor="#284775">
<selectedrowstyle forecolor="#CCFF99" font-bold="True">
BackColor="#009999">
<rowstyle forecolor="#003399" backcolor="White">
<columns> <asp:commandfield showeditbutton="True" showdeletebutton="True" deletetext="Remove" headertext="Add Remove Collegaue">
<asp:boundfield headertext="ColleagueID" readonly="True" datafield="ColleagueID" sortexpression="ColleagueID">
<asp:templatefield headertext="ColleagueName" sortexpression="ColleagueName">
<edititemtemplate>
<asp:textbox id="txtColleagueName" runat="server" text="<%# Bind(" colleaguename")="" %>"="">
<itemtemplate>
<asp:label id="lblColleagueName" runat="server" text="<%# Eval(" colleaguename")="" %>"="">
<asp:templatefield headertext="Mobile" sortexpression="Mobile">
<edititemtemplate>
<asp:textbox id="txtMobile" runat="server" text="<%# Bind(" mobile")="" %>"="">
<itemtemplate>
<asp:label id="lblMobile" runat="server" text="<%# Eval(" mobile")="" %>"="">
<asp:templatefield headertext="Extension" sortexpression="Extension">
<edititemtemplate>
<asp:textbox id="txtExtension" runat="server" text="<%# Bind(" extension")="" %>"="">
<itemtemplate>
<asp:label id="lblExtension" runat="server" text="<%# Eval(" extension")="" %>"="">
<%--<asp:objectdatasource id="objdsColleagueDetails" runat="server" selectmethod="GenericQuery" updatemethod="hdnUpdateColleagues" typename="WAB_DataAccessWS.WAB_DataAccessWS">--%>
<asp:objectdatasource id="objdsColleagueDetails" runat="server" typename="WAB_DataAccessWS.WAB_DataAccessWS" selectmethod="selColleagueDetails" updatemethod="updColleagueDetails">
<selectparameters>
<asp:controlparameter controlid="hdnMainConnStr" name="strConn" propertyname="Value" type="String">
<asp:controlparameter controlid="ddlDepartment" name="intDepartmentID" propertyname="SelectedValue" type="Int32">
<updateparameters>
<asp:controlparameter controlid="hdnMainConnStr" defaultvalue="" name="strConn" propertyname="Value" type="String">
<asp:parameter name="ColleagueName" type="String">
<asp:parameter name="Mobile" type="String">
<asp:parameter name="Extension" type="String">
|
<asp:label id="Label1" runat="server" cssclass="" enableviewstate="false">Add Colleague Details
|
<asp:dropdownlist id="ddlAddColleague" runat="server" cssclass="" datasourceid="objdsAddColleague" datavaluefield="ColleagueName" autopostback="true">
<asp:objectdatasource id="objdsAddColleague" runat="server" selectmethod="GenericQuery" typename="WAB_DataAccessWS.WAB_DataAccessWS">
<selectparameters>
<asp:controlparameter controlid="hdnMainConnStr" name="strConn" propertyname="Value" type="String">
<asp:parameter defaultvalue="exec p_AddColleague" name="strQuery" type="String">
| <asp:button id="btnAdd" cssclass="" runat="server" text="Add Colleague" tooltip="Add Colleague" onclientclick="return confirmAction('Are you sure you want to Add Colleague"> |
thanks for your help
|
|
|
|
|
Hallo,
I have a textbox with onblur event handled with javascript.
I have asp.net button. When i chage the text in textbox and directly click the button, i get a confirm box from the onblur event. How can i make the button event to fire after answering the confirm box.
In other cases like press tab or clicking some other control is not a problem.
example code:
Textbox txt = new TextBox
txt.id = "txt";
txt.attributes.add("onblur","showmsg(this.id)")
Javascript:
function showmsg(id)
{
var x = document.getElementById(id).value;
if (x != "") {
var res = confirm("msg");
if (res == true) {
document.getElementById(id).value = x;
}
else {
document.getElementById(id).value = "";
}
}
}
|
|
|
|
|
document.getelementbyid('yourButtonId').click();
I didn't get any requirements for the signature
|
|
|
|
|
Thanks,
But how to detect that it is button click event after onblur event.
I mean i want to fire the button click event only if the button is pressed immediately after changing text in textbox.
|
|
|
|
|
How come you can not do this the easy way and set the autopostaback of the textbox to true and use the code behind for that event?
I don't have a good answer for you to know if an event occurs immediately after another event. You may have to use a global variable and a javascript timer. I have no idea.
I didn't get any requirements for the signature
|
|
|
|
|
I do not want autopostback on textbox. There should be some way to detect button click event in javascript.
|
|
|
|
|