TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sunil Kumar
NA
22
584
Query string in a textbox and submit to data source
Nov 25 2019 11:17 PM
I have a redirect page url "http://127.0.0.1/HOG/HOG_reporting_Rly.aspx?Monday=Y&Zrly=CR&dt=01-Apr-19
" for rendering another aspx page having grid view (based on query parameters). Now I am trying to set query string "dt" date to textbox in edit mode so that data could be updated but it giving error
Object reference not set to an instance of an object.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:
System.NullReferenceException: Object reference not set to an instance of an object.
Here is my entire code:
<%@ Page Language=
"C#"
%>
<!DOCTYPE html>
<script runat=
"server"
>
public
void
Page_Load(object sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
if
(Request.QueryString[
"dt"
] != null)
{
((TextBox)GridView1.FindControl(
"TextBox17"
)).Text = Request.QueryString[
"dt"
];
}
}
}
</script>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head runat=
"server"
>
<title></title>
<style type=
"text/css"
>
.auto-style1 {
text-align: center;
}
.auto-style2 {
font-family: Tahoma;
font-size: medium;
color: #990000;
font-weight: bold;
}
</style>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<div
class
=
"auto-style1"
>
<span
class
=
"auto-style2"
>HOG Train Master (List of All HOG Trains)</span><br
class
=
"auto-style2"
/>
</div>
<asp:GridView ID=
"GridView1"
runat=
"server"
AutoGenerateColumns=
"False"
DataKeyNames=
"ID"
DataSourceID=
"SqlDataSource1"
HorizontalAlign=
"Center"
Font-Names=
"Tahoma"
Font-Size=
"Small"
AllowSorting=
"True"
>
<Columns>
<asp:BoundField DataField=
"ID"
HeaderText=
"ID"
InsertVisible=
"False"
ReadOnly=
"True"
SortExpression=
"ID"
/>
<asp:TemplateField HeaderText=
"Zrly"
SortExpression=
"Zrly"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox1"
runat=
"server"
Text=
'<%# Bind("Zrly") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label1"
runat=
"server"
Text=
'<%# Bind("Zrly") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Loco_req"
SortExpression=
"Loco_req"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox2"
runat=
"server"
Text=
'<%# Bind("Loco_req") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label2"
runat=
"server"
Text=
'<%# Bind("Loco_req") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Train"
SortExpression=
"Train"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox3"
runat=
"server"
Text=
'<%# Bind("Train") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label3"
runat=
"server"
Text=
'<%# Bind("Train") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Origin"
SortExpression=
"Origin"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox4"
runat=
"server"
Text=
'<%# Bind("Origin") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label4"
runat=
"server"
Text=
'<%# Bind("Origin") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Destin"
SortExpression=
"Destin"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox5"
runat=
"server"
Text=
'<%# Bind("Destin") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label5"
runat=
"server"
Text=
'<%# Bind("Destin") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Rake_link"
SortExpression=
"Rake_link"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox6"
runat=
"server"
Text=
'<%# Bind("Rake_link") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label6"
runat=
"server"
Text=
'<%# Bind("Rake_link") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Loco_link"
SortExpression=
"Loco_link"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox7"
runat=
"server"
Text=
'<%# Bind("Loco_link") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label7"
runat=
"server"
Text=
'<%# Bind("Loco_link") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Saturday"
SortExpression=
"Saturday"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox8"
runat=
"server"
Text=
'<%# Bind("Saturday") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label8"
runat=
"server"
Text=
'<%# Bind("Saturday") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Friday"
SortExpression=
"Friday"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox9"
runat=
"server"
Text=
'<%# Bind("Friday") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label9"
runat=
"server"
Text=
'<%# Bind("Friday") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Thursday"
SortExpression=
"Thursday"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox10"
runat=
"server"
Text=
'<%# Bind("Thursday") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label10"
runat=
"server"
Text=
'<%# Bind("Thursday") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Wednesday"
SortExpression=
"Wednesday"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox11"
runat=
"server"
Text=
'<%# Bind("Wednesday") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label11"
runat=
"server"
Text=
'<%# Bind("Wednesday") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Tuesday"
SortExpression=
"Tuesday"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox12"
runat=
"server"
Text=
'<%# Bind("Tuesday") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label12"
runat=
"server"
Text=
'<%# Bind("Tuesday") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Monday"
SortExpression=
"Monday"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox13"
runat=
"server"
Text=
'<%# Bind("Monday") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label13"
runat=
"server"
Text=
'<%# Bind("Monday") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Sunday"
SortExpression=
"Sunday"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox14"
runat=
"server"
Text=
'<%# Bind("Sunday") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label14"
runat=
"server"
Text=
'<%# Bind("Sunday") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Loco_no"
SortExpression=
"Loco_no"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox15"
runat=
"server"
Text=
'<%# Bind("Loco_no") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label15"
runat=
"server"
Text=
'<%# Bind("Loco_no") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Loco_type"
SortExpression=
"Loco_type"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox16"
runat=
"server"
Text=
'<%# Bind("Loco_type") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label16"
runat=
"server"
Text=
'<%# Bind("Loco_type") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"updated_on"
SortExpression=
"updated_on"
>
<EditItemTemplate>
<asp:TextBox ID=
"TextBox17"
runat=
"server"
Text=
'<%# Bind("updated_on") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID=
"Label17"
runat=
"server"
Text=
'<%# Bind("updated_on") %>'
></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton=
"True"
/>
</Columns>
<HeaderStyle HorizontalAlign=
"Center"
VerticalAlign=
"Middle"
/>
<RowStyle Font-Names=
"Tahoma"
Font-Size=
"Small"
HorizontalAlign=
"Center"
VerticalAlign=
"Middle"
Wrap=
"False"
/>
</asp:GridView>
<asp:SqlDataSource ID=
"SqlDataSource1"
runat=
"server"
CancelSelectOnNullParameter=
"false"
ConnectionString=
"<%$ ConnectionStrings:Loco_bankConnectionString %>"
DeleteCommand=
"DELETE FROM [Hotel_load] WHERE [ID] = @ID"
InsertCommand=
"INSERT INTO [Hotel_load] ([Zrly], [Loco_req], [Train], [Origin], [Destin], [Rake_link], [Loco_link], [Saturday], [Friday], [Thursday], [Wednesday], [Tuesday], [Monday], [Sunday], [Loco_no], [Loco_type], [updated_on]) VALUES (@Zrly, @Loco_req, @Train, @Origin, @Destin, @Rake_link, @Loco_link, @Saturday, @Friday, @Thursday, @Wednesday, @Tuesday, @Monday, @Sunday, @Loco_no, @Loco_type, @updated_on)"
SelectCommand=
"SELECT [ID], [Zrly], [Loco_req], [Train], [Origin], [Destin], [Rake_link], [Loco_link], [Saturday], [Friday], [Thursday], [Wednesday], [Tuesday], [Monday], [Sunday], [Loco_no], [Loco_type], [updated_on] FROM [Hotel_load] WHERE ([Saturday] = @Saturday OR @Saturday IS NULL) AND ([Sunday] = @Sunday OR @Sunday IS NULL) AND ([Monday] = @Monday OR @Monday IS NULL) AND ([Tuesday] = @Tuesday OR @Tuesday IS NULL) AND ([Wednesday] = @Wednesday OR @Wednesday IS NULL) AND ([Thursday] = @Thursday OR @Thursday IS NULL) AND ([Friday] = @Friday OR @Friday IS NULL) AND ([Zrly] = @Zrly) "
UpdateCommand=
"UPDATE [Hotel_load] SET [Zrly] = @Zrly, [Loco_req] = @Loco_req, [Train] = @Train, [Origin] = @Origin, [Destin] = @Destin, [Rake_link] = @Rake_link, [Loco_link] = @Loco_link, [Saturday] = @Saturday, [Friday] = @Friday, [Thursday] = @Thursday, [Wednesday] = @Wednesday, [Tuesday] = @Tuesday, [Monday] = @Monday, [Sunday] = @Sunday, [Loco_no] = @Loco_no, [Loco_type] = @Loco_type, [updated_on] = @updated_on WHERE [ID] = @ID"
>
<DeleteParameters>
<asp:Parameter Name=
"ID"
Type=
"Int32"
/>
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name=
"Zrly"
Type=
"String"
/>
<asp:Parameter Name=
"Loco_req"
Type=
"String"
/>
<asp:Parameter Name=
"Train"
Type=
"String"
/>
<asp:Parameter Name=
"Origin"
Type=
"String"
/>
<asp:Parameter Name=
"Destin"
Type=
"String"
/>
<asp:Parameter Name=
"Rake_link"
Type=
"String"
/>
<asp:Parameter Name=
"Loco_link"
Type=
"String"
/>
<asp:Parameter Name=
"Saturday"
Type=
"String"
/>
<asp:Parameter Name=
"Friday"
Type=
"String"
/>
<asp:Parameter Name=
"Thursday"
Type=
"String"
/>
<asp:Parameter Name=
"Wednesday"
Type=
"String"
/>
<asp:Parameter Name=
"Tuesday"
Type=
"String"
/>
<asp:Parameter Name=
"Monday"
Type=
"String"
/>
<asp:Parameter Name=
"Sunday"
Type=
"String"
/>
<asp:Parameter Name=
"Loco_no"
Type=
"String"
/>
<asp:Parameter Name=
"Loco_type"
Type=
"String"
/>
<asp:Parameter Name=
"updated_on"
Type=
"DateTime"
/>
</InsertParameters>
<SelectParameters>
<asp:QueryStringParameter Name=
"Saturday"
QueryStringField=
"Saturday"
Type=
"String"
/>
<asp:QueryStringParameter Name=
"Sunday"
QueryStringField=
"Sunday"
Type=
"String"
/>
<asp:QueryStringParameter Name=
"Monday"
QueryStringField=
"Monday"
Type=
"String"
/>
<asp:QueryStringParameter Name=
"Tuesday"
QueryStringField=
"Tuesday"
Type=
"String"
/>
<asp:QueryStringParameter Name=
"Wednesday"
QueryStringField=
"Wednesday"
Type=
"String"
/>
<asp:QueryStringParameter Name=
"Thursday"
QueryStringField=
"Thursday"
Type=
"String"
/>
<asp:QueryStringParameter Name=
"Friday"
QueryStringField=
"Friday"
Type=
"String"
/>
<asp:QueryStringParameter Name=
"Zrly"
QueryStringField=
"Zrly"
Type=
"String"
/>
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name=
"Zrly"
Type=
"String"
/>
<asp:Parameter Name=
"Loco_req"
Type=
"String"
/>
<asp:Parameter Name=
"Train"
Type=
"String"
/>
<asp:Parameter Name=
"Origin"
Type=
"String"
/>
<asp:Parameter Name=
"Destin"
Type=
"String"
/>
<asp:Parameter Name=
"Rake_link"
Type=
"String"
/>
<asp:Parameter Name=
"Loco_link"
Type=
"String"
/>
<asp:Parameter Name=
"Saturday"
Type=
"String"
/>
<asp:Parameter Name=
"Friday"
Type=
"String"
/>
<asp:Parameter Name=
"Thursday"
Type=
"String"
/>
<asp:Parameter Name=
"Wednesday"
Type=
"String"
/>
<asp:Parameter Name=
"Tuesday"
Type=
"String"
/>
<asp:Parameter Name=
"Monday"
Type=
"String"
/>
<asp:Parameter Name=
"Sunday"
Type=
"String"
/>
<asp:Parameter Name=
"Loco_no"
Type=
"String"
/>
<asp:Parameter Name=
"Loco_type"
Type=
"String"
/>
<asp:Parameter Name=
"updated_on"
Type=
"DateTime"
/>
<asp:Parameter Name=
"ID"
Type=
"Int32"
/>
</UpdateParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
Reply
Answers (
1
)
Budget Table need to get next budget id ans amount
API show 400 Bad Request on Client Side